mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-21 17:01:35 +00:00
signer interface for validators
This commit is contained in:
19
node/node.go
19
node/node.go
@ -41,7 +41,15 @@ type Node struct {
|
||||
privKey crypto.PrivKeyEd25519
|
||||
}
|
||||
|
||||
func NewNode() *Node {
|
||||
func NewNodeDefaultPrivVal() *Node {
|
||||
// Get PrivValidator
|
||||
privValidatorFile := config.GetString("priv_validator_file")
|
||||
privValidator := types.LoadOrGenPrivValidator(privValidatorFile)
|
||||
|
||||
return NewNode(privValidator)
|
||||
}
|
||||
|
||||
func NewNode(privValidator *types.PrivValidator) *Node {
|
||||
// Get BlockStore
|
||||
blockStoreDB := dbm.GetDB("blockstore")
|
||||
blockStore := bc.NewBlockStore(blockStoreDB)
|
||||
@ -58,10 +66,6 @@ func NewNode() *Node {
|
||||
// add the chainid to the global config
|
||||
config.Set("chain_id", state.ChainID)
|
||||
|
||||
// Get PrivValidator
|
||||
privValidatorFile := config.GetString("priv_validator_file")
|
||||
privValidator := types.LoadOrGenPrivValidator(privValidatorFile)
|
||||
|
||||
// Generate node PrivKey
|
||||
privKey := crypto.GenPrivKeyEd25519()
|
||||
|
||||
@ -249,6 +253,9 @@ func makeNodeInfo(sw *p2p.Switch, privKey crypto.PrivKeyEd25519) *p2p.NodeInfo {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Users wishing to use an external signer for their validators
|
||||
// should fork tendermint/tendermint and implement RunNode to
|
||||
// load their custom priv validator and call NewNode(privVal)
|
||||
func RunNode() {
|
||||
|
||||
// Wait until the genesis doc becomes available
|
||||
@ -274,7 +281,7 @@ func RunNode() {
|
||||
}
|
||||
|
||||
// Create & start node
|
||||
n := NewNode()
|
||||
n := NewNodeDefaultPrivVal()
|
||||
l := p2p.NewDefaultListener("tcp", config.GetString("node_laddr"), config.GetBool("skip_upnp"))
|
||||
n.AddListener(l)
|
||||
err := n.Start()
|
||||
|
Reference in New Issue
Block a user