diff --git a/binary/README.md b/binary/README.md index 2dfa79192..c490d0e57 100644 --- a/binary/README.md +++ b/binary/README.md @@ -3,6 +3,8 @@ This documentation is out of date. * 0x00 is reserved as a nil byte for RegisterInterface * moved TypeByte() into RegisterInterface/ConcreteType +* Pointers that don't have a declared TypeByte() are + encoded with a leading 0x00 (nil) or 0x01. # `tendermint/binary` diff --git a/consensus/reactor.go b/consensus/reactor.go index 548ef9510..d1edfc481 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -24,7 +24,7 @@ const ( DataChannel = byte(0x21) VoteChannel = byte(0x22) - peerStateKey = "ConsensusReactor.peerState" + PeerStateKey = "ConsensusReactor.peerState" peerGossipSleepDuration = 100 * time.Millisecond // Time to sleep if there's nothing to send. ) @@ -106,7 +106,7 @@ func (conR *ConsensusReactor) AddPeer(peer *p2p.Peer) { // Create peerState for peer peerState := NewPeerState(peer) - peer.Data.Set(peerStateKey, peerState) + peer.Data.Set(PeerStateKey, peerState) // Begin gossip routines for this peer. go conR.gossipDataRoutine(peer, peerState) @@ -121,7 +121,7 @@ func (conR *ConsensusReactor) RemovePeer(peer *p2p.Peer, reason interface{}) { if !conR.IsRunning() { return } - //peer.Data.Get(peerStateKey).(*PeerState).Disconnect() + //peer.Data.Get(PeerStateKey).(*PeerState).Disconnect() } // Implements Reactor @@ -132,7 +132,7 @@ func (conR *ConsensusReactor) Receive(chId byte, peer *p2p.Peer, msgBytes []byte // Get round state rs := conR.conS.GetRoundState() - ps := peer.Data.Get(peerStateKey).(*PeerState) + ps := peer.Data.Get(PeerStateKey).(*PeerState) _, msg_, err := DecodeMessage(msgBytes) if err != nil { log.Warn("Error decoding message", "channel", chId, "peer", peer, "msg", msg_, "error", err, "bytes", msgBytes) diff --git a/node/node.go b/node/node.go index 3bbd2897f..e7802ff25 100644 --- a/node/node.go +++ b/node/node.go @@ -178,6 +178,7 @@ func (n *Node) dialSeed(addr *p2p.NetAddress) { func (n *Node) StartRPC() { core.SetBlockStore(n.blockStore) core.SetConsensusState(n.consensusState) + core.SetConsensusReactor(n.consensusReactor) core.SetMempoolReactor(n.mempoolReactor) core.SetSwitch(n.sw) diff --git a/rpc/core/consensus.go b/rpc/core/consensus.go index c74cf8cc4..059bc64a3 100644 --- a/rpc/core/consensus.go +++ b/rpc/core/consensus.go @@ -2,6 +2,7 @@ package core import ( "github.com/tendermint/tendermint/binary" + cm "github.com/tendermint/tendermint/consensus" ctypes "github.com/tendermint/tendermint/rpc/core/types" sm "github.com/tendermint/tendermint/state" ) @@ -26,6 +27,14 @@ func ListValidators() (*ctypes.ResponseListValidators, error) { } func DumpConsensusState() (*ctypes.ResponseDumpConsensusState, error) { - jsonBytes := binary.JSONBytes(consensusState.GetRoundState()) - return &ctypes.ResponseDumpConsensusState{string(jsonBytes)}, nil + roundState := consensusState.GetRoundState() + peerRoundStates := []string{} + for _, peer := range p2pSwitch.Peers().List() { + // TODO: clean this up? + peerState := peer.Data.Get(cm.PeerStateKey).(*cm.PeerState) + peerRoundState := peerState.GetRoundState() + peerRoundStateStr := peer.Key + ":" + string(binary.JSONBytes(peerRoundState)) + peerRoundStates = append(peerRoundStates, peerRoundStateStr) + } + return &ctypes.ResponseDumpConsensusState{roundState.String(), peerRoundStates}, nil } diff --git a/rpc/core/pipe.go b/rpc/core/pipe.go index c4548a75b..0d1990c14 100644 --- a/rpc/core/pipe.go +++ b/rpc/core/pipe.go @@ -10,6 +10,7 @@ import ( var blockStore *bc.BlockStore var consensusState *consensus.ConsensusState +var consensusReactor *consensus.ConsensusReactor var mempoolReactor *mempl.MempoolReactor var p2pSwitch *p2p.Switch @@ -21,6 +22,10 @@ func SetConsensusState(cs *consensus.ConsensusState) { consensusState = cs } +func SetConsensusReactor(cr *consensus.ConsensusReactor) { + consensusReactor = cr +} + func SetMempoolReactor(mr *mempl.MempoolReactor) { mempoolReactor = mr } @@ -29,6 +34,7 @@ func SetSwitch(sw *p2p.Switch) { p2pSwitch = sw } +// JAE Why is this here? func SetPrivValidator(priv *state.PrivValidator) { - consensusState.SetPrivValidator(priv) + consensusReactor.SetPrivValidator(priv) } diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index b3b13c030..79d42e039 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -93,5 +93,6 @@ type ResponseListValidators struct { } type ResponseDumpConsensusState struct { - ConsensusState string + RoundState string + PeerRoundStates []string }