diff --git a/node/node.go b/node/node.go index db95fe22..5ad30180 100644 --- a/node/node.go +++ b/node/node.go @@ -45,7 +45,10 @@ type Node struct { privKey crypto.PrivKeyEd25519 } -func NewNode(privValidator *types.PrivValidator) *Node { +func NewNode(privValidator *types.PrivValidator, getProxyApp func(proxyAddr string, appHash []byte) proxy.AppConn) *Node { + + EnsureDir(config.GetString("db_dir"), 0700) // incase we use memdb, cswal still gets written here + // Get BlockStore blockStoreDB := dbm.GetDB("blockstore") blockStore := bc.NewBlockStore(blockStoreDB) @@ -249,7 +252,7 @@ func makeNodeInfo(sw *p2p.Switch, privKey crypto.PrivKeyEd25519) *p2p.NodeInfo { // Get a connection to the proxyAppConn addr. // Check the current hash, and panic if it doesn't match. -func getProxyApp(addr string, hash []byte) (proxyAppConn proxy.AppConn) { +func GetProxyApp(addr string, hash []byte) (proxyAppConn proxy.AppConn) { // use local app (for testing) switch addr { case "nilapp": @@ -297,7 +300,7 @@ func getState() *sm.State { // 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) +// load their custom priv validator and call NewNode(privVal, getProxyFunc) func RunNode() { // Wait until the genesis doc becomes available genDocFile := config.GetString("genesis_file") @@ -326,7 +329,7 @@ func RunNode() { privValidator := types.LoadOrGenPrivValidator(privValidatorFile) // Create & start node - n := NewNode(privValidator) + n := NewNode(privValidator, GetProxyApp) l := p2p.NewDefaultListener("tcp", config.GetString("node_laddr"), config.GetBool("skip_upnp")) n.AddListener(l) err := n.Start() @@ -356,6 +359,14 @@ func RunNode() { }) } +func (n *Node) NodeInfo() *p2p.NodeInfo { + return n.sw.NodeInfo() +} + +func (n *Node) DialSeeds(seeds []string) { + n.sw.DialSeeds(seeds) +} + //------------------------------------------------------------------------------ // replay @@ -372,8 +383,8 @@ func newConsensusState() *consensus.ConsensusState { // Create two proxyAppConn connections, // one for the consensus and one for the mempool. proxyAddr := config.GetString("proxy_app") - proxyAppConnMempool := getProxyApp(proxyAddr, state.AppHash) - proxyAppConnConsensus := getProxyApp(proxyAddr, state.AppHash) + proxyAppConnMempool := GetProxyApp(proxyAddr, state.AppHash) + proxyAppConnConsensus := GetProxyApp(proxyAddr, state.AppHash) // add the chainid to the global config config.Set("chain_id", state.ChainID) diff --git a/node/node_test.go b/node/node_test.go index 09801d50..0f397f6e 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -20,7 +20,7 @@ func TestNodeStartStop(t *testing.T) { privValidator := types.LoadOrGenPrivValidator(privValidatorFile) // Create & start node - n := NewNode(privValidator) + n := NewNode(privValidator, GetProxyApp) l := p2p.NewDefaultListener("tcp", config.GetString("node_laddr"), config.GetBool("skip_upnp")) n.AddListener(l) n.Start() diff --git a/rpc/test/helpers.go b/rpc/test/helpers.go index 421fdbb8..48ec8ccb 100644 --- a/rpc/test/helpers.go +++ b/rpc/test/helpers.go @@ -51,7 +51,7 @@ func newNode(ready chan struct{}) { // Create & start node privValidatorFile := config.GetString("priv_validator_file") privValidator := types.LoadOrGenPrivValidator(privValidatorFile) - node = nm.NewNode(privValidator) + node = nm.NewNode(privValidator, nm.GetProxyApp) l := p2p.NewDefaultListener("tcp", config.GetString("node_laddr"), true) node.AddListener(l) node.Start()