From 08d7980d80ed352a1b3baa0921a16fc184a51678 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Mon, 21 Dec 2015 14:48:44 -0800 Subject: [PATCH] Conform to go-wire new TypeByte behavior --- blockchain/reactor.go | 8 ++++---- consensus/reactor.go | 16 ++++++++-------- mempool/reactor.go | 2 +- proxy/remote_app_context.go | 2 +- types/genesis.go | 6 +++--- types/validator.go | 10 +++++----- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/blockchain/reactor.go b/blockchain/reactor.go index 9870367c..b66a17a4 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -113,7 +113,7 @@ func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor { // Implements Reactor func (bcR *BlockchainReactor) AddPeer(peer *p2p.Peer) { // Send peer our state. - peer.Send(BlockchainChannel, &bcStatusResponseMessage{bcR.store.Height()}) + peer.Send(BlockchainChannel, struct{ BlockchainMessage }{&bcStatusResponseMessage{bcR.store.Height()}}) } // Implements Reactor @@ -138,7 +138,7 @@ func (bcR *BlockchainReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte) block := bcR.store.LoadBlock(msg.Height) if block != nil { msg := &bcBlockResponseMessage{Block: block} - queued := src.TrySend(BlockchainChannel, msg) + queued := src.TrySend(BlockchainChannel, struct{ BlockchainMessage }{msg}) if !queued { // queue is full, just ignore. } @@ -150,7 +150,7 @@ func (bcR *BlockchainReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte) bcR.pool.AddBlock(src.Key, msg.Block, len(msgBytes)) case *bcStatusRequestMessage: // Send peer our state. - queued := src.TrySend(BlockchainChannel, &bcStatusResponseMessage{bcR.store.Height()}) + queued := src.TrySend(BlockchainChannel, struct{ BlockchainMessage }{&bcStatusResponseMessage{bcR.store.Height()}}) if !queued { // sorry } @@ -180,7 +180,7 @@ FOR_LOOP: continue FOR_LOOP // Peer has since been disconnected. } msg := &bcBlockRequestMessage{request.Height} - queued := peer.TrySend(BlockchainChannel, msg) + queued := peer.TrySend(BlockchainChannel, struct{ BlockchainMessage }{msg}) if !queued { // We couldn't make the request, send-queue full. // The pool handles timeouts, just let it go. diff --git a/consensus/reactor.go b/consensus/reactor.go index b0bdce93..57e6af4e 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -272,7 +272,7 @@ func (conR *ConsensusReactor) broadcastHasVoteMessage(vote *types.Vote, index in prs := ps.GetRoundState() if prs.Height == vote.Height { // TODO: Also filter on round? - peer.TrySend(StateChannel, msg) + peer.TrySend(StateChannel, struct{ ConsensusMessage }{msg}) } else { // Height doesn't match // TODO: check a field, maybe CatchupCommitRound? @@ -304,10 +304,10 @@ func (conR *ConsensusReactor) sendNewRoundStepMessage(peer *p2p.Peer) { rs := conR.conS.GetRoundState() nrsMsg, csMsg := makeRoundStepMessages(rs) if nrsMsg != nil { - peer.Send(StateChannel, nrsMsg) + peer.Send(StateChannel, struct{ ConsensusMessage }{nrsMsg}) } if csMsg != nil { - peer.Send(StateChannel, csMsg) + peer.Send(StateChannel, struct{ ConsensusMessage }{csMsg}) } } @@ -334,7 +334,7 @@ OUTER_LOOP: Round: rs.Round, // This tells peer that this part applies to us. Part: part, } - peer.Send(DataChannel, msg) + peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) ps.SetHasProposalBlockPart(prs.Height, prs.Round, index) continue OUTER_LOOP } @@ -366,7 +366,7 @@ OUTER_LOOP: Round: prs.Round, // Not our height, so it doesn't matter. Part: part, } - peer.Send(DataChannel, msg) + peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) ps.SetHasProposalBlockPart(prs.Height, prs.Round, index) continue OUTER_LOOP } else { @@ -393,7 +393,7 @@ OUTER_LOOP: // Proposal { msg := &ProposalMessage{Proposal: rs.Proposal} - peer.Send(DataChannel, msg) + peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) ps.SetHasProposal(rs.Proposal) } // ProposalPOL. @@ -406,7 +406,7 @@ OUTER_LOOP: ProposalPOLRound: rs.Proposal.POLRound, ProposalPOL: rs.Votes.Prevotes(rs.Proposal.POLRound).BitArray(), } - peer.Send(DataChannel, msg) + peer.Send(DataChannel, struct{ ConsensusMessage }{msg}) } continue OUTER_LOOP } @@ -614,7 +614,7 @@ func (ps *PeerState) SetHasProposalBlockPart(height int, round int, index int) { func (ps *PeerState) PickSendVote(votes types.VoteSetReader) (ok bool) { if index, vote, ok := ps.PickVoteToSend(votes); ok { msg := &VoteMessage{index, vote} - ps.Peer.Send(VoteChannel, msg) + ps.Peer.Send(VoteChannel, struct{ ConsensusMessage }{msg}) return true } return false diff --git a/mempool/reactor.go b/mempool/reactor.go index 13bb20ad..587cacd4 100644 --- a/mempool/reactor.go +++ b/mempool/reactor.go @@ -123,7 +123,7 @@ func (memR *MempoolReactor) broadcastTxRoutine(peer Peer) { } // send memTx msg := &TxMessage{Tx: memTx.tx} - success := peer.Send(MempoolChannel, msg) + success := peer.Send(MempoolChannel, struct{ MempoolMessage }{msg}) if !success { time.Sleep(peerCatchupSleepIntervalMS * time.Millisecond) continue diff --git a/proxy/remote_app_context.go b/proxy/remote_app_context.go index a15aebca..9bd0325c 100644 --- a/proxy/remote_app_context.go +++ b/proxy/remote_app_context.go @@ -92,7 +92,7 @@ func (app *remoteAppContext) sendRequestsRoutine() { app.willSendReq(reqres) - wire.WriteBinaryLengthPrefixed(reqres.Request, app.bufWriter, &n, &err) // Length prefix + wire.WriteBinaryLengthPrefixed(struct{ tmsp.Request }{reqres.Request}, app.bufWriter, &n, &err) // Length prefix if err != nil { app.StopForError(err) return diff --git a/types/genesis.go b/types/genesis.go index 95d54f47..2c5fc827 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -17,9 +17,9 @@ var GenDocKey = []byte("GenDocKey") // core types for a genesis definition type GenesisValidator struct { - PubKey crypto.PubKeyEd25519 `json:"pub_key"` - Amount int64 `json:"amount"` - Name string `json:"name"` + PubKey crypto.PubKey `json:"pub_key"` + Amount int64 `json:"amount"` + Name string `json:"name"` } type GenesisDoc struct { diff --git a/types/validator.go b/types/validator.go index f68f5892..944ce9d9 100644 --- a/types/validator.go +++ b/types/validator.go @@ -14,11 +14,11 @@ import ( // Also persisted with the state, but fields change // every height|round so they don't go in merkle.Tree type Validator struct { - Address []byte `json:"address"` - PubKey crypto.PubKeyEd25519 `json:"pub_key"` - LastCommitHeight int `json:"last_commit_height"` - VotingPower int64 `json:"voting_power"` - Accum int64 `json:"accum"` + Address []byte `json:"address"` + PubKey crypto.PubKey `json:"pub_key"` + LastCommitHeight int `json:"last_commit_height"` + VotingPower int64 `json:"voting_power"` + Accum int64 `json:"accum"` } // Creates a new copy of the validator so we can mutate accum.