signer interface for validators

This commit is contained in:
Ethan Buchman
2015-11-05 02:09:43 +02:00
parent c3a8f202ab
commit 28ec3d48fa
4 changed files with 54 additions and 20 deletions

View File

@ -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()