mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-13 11:34:17 +00:00
Dot import -> named import
Changed modulename_ to short module names Also removed Unreader, replaced with PrefixdReader in select locations
This commit is contained in:
+13
-13
@@ -8,11 +8,11 @@ import (
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/consensus"
|
||||
db_ "github.com/tendermint/tendermint/db"
|
||||
mempool_ "github.com/tendermint/tendermint/mempool"
|
||||
dbm "github.com/tendermint/tendermint/db"
|
||||
mempl "github.com/tendermint/tendermint/mempool"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
"github.com/tendermint/tendermint/rpc"
|
||||
state_ "github.com/tendermint/tendermint/state"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
type Node struct {
|
||||
@@ -21,29 +21,29 @@ type Node struct {
|
||||
book *p2p.AddrBook
|
||||
pexReactor *p2p.PEXReactor
|
||||
blockStore *block.BlockStore
|
||||
mempoolReactor *mempool_.MempoolReactor
|
||||
mempoolReactor *mempl.MempoolReactor
|
||||
consensusState *consensus.ConsensusState
|
||||
consensusReactor *consensus.ConsensusReactor
|
||||
privValidator *state_.PrivValidator
|
||||
privValidator *sm.PrivValidator
|
||||
}
|
||||
|
||||
func NewNode() *Node {
|
||||
// Get BlockStore
|
||||
blockStoreDB := db_.GetDB("blockstore")
|
||||
blockStoreDB := dbm.GetDB("blockstore")
|
||||
blockStore := block.NewBlockStore(blockStoreDB)
|
||||
|
||||
// Get State
|
||||
stateDB := db_.GetDB("state")
|
||||
state := state_.LoadState(stateDB)
|
||||
stateDB := dbm.GetDB("state")
|
||||
state := sm.LoadState(stateDB)
|
||||
if state == nil {
|
||||
state = state_.MakeGenesisStateFromFile(stateDB, config.App.GetString("GenesisFile"))
|
||||
state = sm.MakeGenesisStateFromFile(stateDB, config.App.GetString("GenesisFile"))
|
||||
state.Save()
|
||||
}
|
||||
|
||||
// Get PrivValidator
|
||||
var privValidator *state_.PrivValidator
|
||||
var privValidator *sm.PrivValidator
|
||||
if _, err := os.Stat(config.App.GetString("PrivValidatorFile")); err == nil {
|
||||
privValidator = state_.LoadPrivValidator(config.App.GetString("PrivValidatorFile"))
|
||||
privValidator = sm.LoadPrivValidator(config.App.GetString("PrivValidatorFile"))
|
||||
log.Info("Loaded PrivValidator", "file", config.App.GetString("PrivValidatorFile"), "privValidator", privValidator)
|
||||
} else {
|
||||
log.Info("No PrivValidator found", "file", config.App.GetString("PrivValidatorFile"))
|
||||
@@ -54,8 +54,8 @@ func NewNode() *Node {
|
||||
pexReactor := p2p.NewPEXReactor(book)
|
||||
|
||||
// Get MempoolReactor
|
||||
mempool := mempool_.NewMempool(state.Copy())
|
||||
mempoolReactor := mempool_.NewMempoolReactor(mempool)
|
||||
mempool := mempl.NewMempool(state.Copy())
|
||||
mempoolReactor := mempl.NewMempoolReactor(mempool)
|
||||
|
||||
// Get ConsensusReactor
|
||||
consensusState := consensus.NewConsensusState(state, blockStore, mempoolReactor)
|
||||
|
||||
+2
-2
@@ -4,12 +4,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/account"
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
)
|
||||
|
||||
func gen_account() {
|
||||
privAccount := account.GenPrivAccount()
|
||||
privAccountJSONBytes := JSONBytes(privAccount)
|
||||
privAccountJSONBytes := binary.JSONBytes(privAccount)
|
||||
fmt.Printf(`Generated a new account!
|
||||
|
||||
%v
|
||||
|
||||
+17
-17
@@ -8,12 +8,12 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
account_ "github.com/tendermint/tendermint/account"
|
||||
binary "github.com/tendermint/tendermint/binary"
|
||||
block_ "github.com/tendermint/tendermint/block"
|
||||
"github.com/tendermint/tendermint/account"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
"github.com/tendermint/tendermint/block"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
db_ "github.com/tendermint/tendermint/db"
|
||||
state_ "github.com/tendermint/tendermint/state"
|
||||
dbm "github.com/tendermint/tendermint/db"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
func getString(prompt string) string {
|
||||
@@ -44,19 +44,19 @@ func getUint64(prompt string) uint64 {
|
||||
func gen_tx() {
|
||||
|
||||
// Get State, which may be nil.
|
||||
stateDB := db_.GetDB("state")
|
||||
state := state_.LoadState(stateDB)
|
||||
stateDB := dbm.GetDB("state")
|
||||
state := sm.LoadState(stateDB)
|
||||
|
||||
// Get source pubkey
|
||||
srcPubKeyBytes := getByteSliceFromHex("Enter source pubkey: ")
|
||||
r, n, err := bytes.NewReader(srcPubKeyBytes), new(int64), new(error)
|
||||
srcPubKey := binary.ReadBinary(struct{ account_.PubKey }{}, r, n, err).(struct{ account_.PubKey }).PubKey
|
||||
srcPubKey := binary.ReadBinary(struct{ account.PubKey }{}, r, n, err).(struct{ account.PubKey }).PubKey
|
||||
if *err != nil {
|
||||
Exit(Fmt("Invalid PubKey. Error: %v", err))
|
||||
}
|
||||
|
||||
// Get the state of the account.
|
||||
var srcAccount *account_.Account
|
||||
var srcAccount *account.Account
|
||||
var srcAccountAddress = srcPubKey.Address()
|
||||
var srcAccountBalanceStr = "unknown"
|
||||
var srcAccountSequenceStr = "unknown"
|
||||
@@ -80,18 +80,18 @@ func gen_tx() {
|
||||
dstSendAmount := getUint64(Fmt("Enter amount to send to %X: ", dstAddress))
|
||||
|
||||
// Construct SendTx
|
||||
tx := &block_.SendTx{
|
||||
Inputs: []*block_.TxInput{
|
||||
&block_.TxInput{
|
||||
tx := &block.SendTx{
|
||||
Inputs: []*block.TxInput{
|
||||
&block.TxInput{
|
||||
Address: srcAddress,
|
||||
Amount: srcSendAmount,
|
||||
Sequence: srcSendSequence,
|
||||
Signature: account_.SignatureEd25519{},
|
||||
Signature: account.SignatureEd25519{},
|
||||
PubKey: srcPubKey,
|
||||
},
|
||||
},
|
||||
Outputs: []*block_.TxOutput{
|
||||
&block_.TxOutput{
|
||||
Outputs: []*block.TxOutput{
|
||||
&block.TxOutput{
|
||||
Address: dstAddress,
|
||||
Amount: dstSendAmount,
|
||||
},
|
||||
@@ -104,12 +104,12 @@ func gen_tx() {
|
||||
// Get source privkey (for signing)
|
||||
srcPrivKeyBytes := getByteSliceFromHex("Enter source privkey (for signing): ")
|
||||
r, n, err = bytes.NewReader(srcPrivKeyBytes), new(int64), new(error)
|
||||
srcPrivKey := binary.ReadBinary(struct{ account_.PrivKey }{}, r, n, err).(struct{ account_.PrivKey }).PrivKey
|
||||
srcPrivKey := binary.ReadBinary(struct{ account.PrivKey }{}, r, n, err).(struct{ account.PrivKey }).PrivKey
|
||||
if *err != nil {
|
||||
Exit(Fmt("Invalid PrivKey. Error: %v", err))
|
||||
}
|
||||
|
||||
// Sign
|
||||
tx.Inputs[0].Signature = srcPrivKey.Sign(account_.SignBytes(tx))
|
||||
tx.Inputs[0].Signature = srcPrivKey.Sign(account.SignBytes(tx))
|
||||
fmt.Printf("Signed tx: %X\n", binary.BinaryBytes(tx))
|
||||
}
|
||||
|
||||
@@ -3,16 +3,15 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/state"
|
||||
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
func gen_validator() {
|
||||
|
||||
privValidator := state.GenPrivValidator()
|
||||
privValidatorJSONBytes := JSONBytes(privValidator)
|
||||
privValidator := sm.GenPrivValidator()
|
||||
privValidatorJSONBytes := binary.JSONBytes(privValidator)
|
||||
fmt.Printf(`Generated a new validator!
|
||||
Paste the following JSON into your %v file
|
||||
|
||||
|
||||
Reference in New Issue
Block a user