diff --git a/config/config.go b/config/config.go index 47ff0510a..8366d4d9e 100644 --- a/config/config.go +++ b/config/config.go @@ -125,6 +125,7 @@ var DefaultGenesis = `{ // NOTE: If you change this, maybe also change defaultConfig func initDefaults(rootDir string) { app.SetDefault("network", "tendermint_testnet0") + app.SetDefault("version", "0.2.1") app.SetDefault("genesis_file", rootDir+"/genesis.json") app.SetDefault("moniker", "anonymous") app.SetDefault("node_laddr", "0.0.0.0:46656") diff --git a/crawler/crawl.go b/crawler/crawl.go index a44f360e6..a3e5cf722 100644 --- a/crawler/crawl.go +++ b/crawler/crawl.go @@ -32,7 +32,7 @@ type Node struct { client *NodeClient LastSeen time.Time - GenesisHash []byte + Network string BlockHeight uint BlockHistory map[uint]time.Time // when we saw each block NetInfo *rpctypes.ResponseNetInfo @@ -50,7 +50,7 @@ func (n *Node) Address() string { // Set the basic status and network info for a node from RPC responses func (n *Node) SetInfo(status *rpctypes.ResponseStatus, netinfo *rpctypes.ResponseNetInfo) { n.LastSeen = time.Now() - n.GenesisHash = status.GenesisHash + n.Network = status.Network n.BlockHeight = status.LatestBlockHeight n.NetInfo = netinfo // n.Validator diff --git a/node/node.go b/node/node.go index 9e05d74f7..9a81992d6 100644 --- a/node/node.go +++ b/node/node.go @@ -187,6 +187,7 @@ func (n *Node) StartRPC() { core.SetConsensusReactor(n.consensusReactor) core.SetMempoolReactor(n.mempoolReactor) core.SetSwitch(n.sw) + core.SetPrivValidator(n.privValidator) listenAddr := config.App().GetString("rpc_laddr") mux := http.NewServeMux() @@ -215,7 +216,7 @@ func makeNodeInfo(sw *p2p.Switch) *types.NodeInfo { nodeInfo := &types.NodeInfo{ Network: config.App().GetString("network"), Moniker: config.App().GetString("moniker"), - Version: "0.2.0", // Everything is in Big Endian. + Version: config.App().GetString("version"), } if !sw.IsListening() { return nodeInfo diff --git a/rpc/core/net.go b/rpc/core/net.go index fc77bc24f..d46f48fd1 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -26,15 +26,21 @@ func Status() (*ctypes.ResponseStatus, error) { latestBlockTime = latestBlockMeta.Header.Time.UnixNano() } - return &ctypes.ResponseStatus{genesisHash, config.App().GetString("network"), latestBlockHash, latestHeight, latestBlockTime}, nil + return &ctypes.ResponseStatus{ + Moniker: config.App().GetString("moniker"), + Network: config.App().GetString("network"), + Version: config.App().GetString("version"), + GenesisHash: genesisHash, + PubKey: privValidator.PubKey, + LatestBlockHash: latestBlockHash, + LatestBlockHeight: latestHeight, + LatestBlockTime: latestBlockTime}, nil } //----------------------------------------------------------------------------- func NetInfo() (*ctypes.ResponseNetInfo, error) { listening := p2pSwitch.IsListening() - moniker := config.App().GetString("moniker") - network := config.App().GetString("network") listeners := []string{} for _, listener := range p2pSwitch.Listeners() { listeners = append(listeners, listener.String()) @@ -47,8 +53,6 @@ func NetInfo() (*ctypes.ResponseNetInfo, error) { }) } return &ctypes.ResponseNetInfo{ - Moniker: moniker, - Network: network, Listening: listening, Listeners: listeners, Peers: peers, diff --git a/rpc/core/pipe.go b/rpc/core/pipe.go index 0d1990c14..4ec0b9061 100644 --- a/rpc/core/pipe.go +++ b/rpc/core/pipe.go @@ -13,6 +13,7 @@ var consensusState *consensus.ConsensusState var consensusReactor *consensus.ConsensusReactor var mempoolReactor *mempl.MempoolReactor var p2pSwitch *p2p.Switch +var privValidator *state.PrivValidator func SetBlockStore(bs *bc.BlockStore) { blockStore = bs @@ -34,7 +35,6 @@ func SetSwitch(sw *p2p.Switch) { p2pSwitch = sw } -// JAE Why is this here? -func SetPrivValidator(priv *state.PrivValidator) { - consensusReactor.SetPrivValidator(priv) +func SetPrivValidator(pv *state.PrivValidator) { + privValidator = pv } diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index edb781469..3934fcaab 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -65,16 +65,17 @@ type Receipt struct { } type ResponseStatus struct { - GenesisHash []byte `json:"genesis_hash"` - Network string `json:"network"` - LatestBlockHash []byte `json:"latest_block_hash"` - LatestBlockHeight uint `json:"latest_block_height"` - LatestBlockTime int64 `json:"latest_block_time"` // nano + Moniker string `json:"moniker"` + Network string `json:"network"` + Version string `json:"version"` + GenesisHash []byte `json:"genesis_hash"` + PubKey account.PubKey `json:"pub_key"` + LatestBlockHash []byte `json:"latest_block_hash"` + LatestBlockHeight uint `json:"latest_block_height"` + LatestBlockTime int64 `json:"latest_block_time"` // nano } type ResponseNetInfo struct { - Moniker string `json:"moniker"` - Network string `json:"network"` Listening bool `json:"listening"` Listeners []string `json:"listeners"` Peers []Peer `json:"peers"` diff --git a/rpc/test/tests_test.go b/rpc/test/tests_test.go index 3694ee506..3361de6fd 100644 --- a/rpc/test/tests_test.go +++ b/rpc/test/tests_test.go @@ -5,7 +5,6 @@ import ( "fmt" . "github.com/tendermint/tendermint/common" "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/types" "testing" ) @@ -91,9 +90,6 @@ func testGetStorage(t *testing.T, typ string) { unsubscribe(t, con, eid) con.Close() }() - priv := state.LoadPrivValidator(".tendermint/priv_validator.json") - _ = priv - //core.SetPrivValidator(priv) amt := uint64(1100) code := []byte{0x60, 0x5, 0x60, 0x1, 0x55}