Conform to go-wire new TypeByte behavior
This commit is contained in:
parent
5bf7796004
commit
08d7980d80
|
@ -113,7 +113,7 @@ func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor {
|
||||||
// Implements Reactor
|
// Implements Reactor
|
||||||
func (bcR *BlockchainReactor) AddPeer(peer *p2p.Peer) {
|
func (bcR *BlockchainReactor) AddPeer(peer *p2p.Peer) {
|
||||||
// Send peer our state.
|
// Send peer our state.
|
||||||
peer.Send(BlockchainChannel, &bcStatusResponseMessage{bcR.store.Height()})
|
peer.Send(BlockchainChannel, struct{ BlockchainMessage }{&bcStatusResponseMessage{bcR.store.Height()}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements Reactor
|
// Implements Reactor
|
||||||
|
@ -138,7 +138,7 @@ func (bcR *BlockchainReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)
|
||||||
block := bcR.store.LoadBlock(msg.Height)
|
block := bcR.store.LoadBlock(msg.Height)
|
||||||
if block != nil {
|
if block != nil {
|
||||||
msg := &bcBlockResponseMessage{Block: block}
|
msg := &bcBlockResponseMessage{Block: block}
|
||||||
queued := src.TrySend(BlockchainChannel, msg)
|
queued := src.TrySend(BlockchainChannel, struct{ BlockchainMessage }{msg})
|
||||||
if !queued {
|
if !queued {
|
||||||
// queue is full, just ignore.
|
// 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))
|
bcR.pool.AddBlock(src.Key, msg.Block, len(msgBytes))
|
||||||
case *bcStatusRequestMessage:
|
case *bcStatusRequestMessage:
|
||||||
// Send peer our state.
|
// Send peer our state.
|
||||||
queued := src.TrySend(BlockchainChannel, &bcStatusResponseMessage{bcR.store.Height()})
|
queued := src.TrySend(BlockchainChannel, struct{ BlockchainMessage }{&bcStatusResponseMessage{bcR.store.Height()}})
|
||||||
if !queued {
|
if !queued {
|
||||||
// sorry
|
// sorry
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ FOR_LOOP:
|
||||||
continue FOR_LOOP // Peer has since been disconnected.
|
continue FOR_LOOP // Peer has since been disconnected.
|
||||||
}
|
}
|
||||||
msg := &bcBlockRequestMessage{request.Height}
|
msg := &bcBlockRequestMessage{request.Height}
|
||||||
queued := peer.TrySend(BlockchainChannel, msg)
|
queued := peer.TrySend(BlockchainChannel, struct{ BlockchainMessage }{msg})
|
||||||
if !queued {
|
if !queued {
|
||||||
// We couldn't make the request, send-queue full.
|
// We couldn't make the request, send-queue full.
|
||||||
// The pool handles timeouts, just let it go.
|
// The pool handles timeouts, just let it go.
|
||||||
|
|
|
@ -272,7 +272,7 @@ func (conR *ConsensusReactor) broadcastHasVoteMessage(vote *types.Vote, index in
|
||||||
prs := ps.GetRoundState()
|
prs := ps.GetRoundState()
|
||||||
if prs.Height == vote.Height {
|
if prs.Height == vote.Height {
|
||||||
// TODO: Also filter on round?
|
// TODO: Also filter on round?
|
||||||
peer.TrySend(StateChannel, msg)
|
peer.TrySend(StateChannel, struct{ ConsensusMessage }{msg})
|
||||||
} else {
|
} else {
|
||||||
// Height doesn't match
|
// Height doesn't match
|
||||||
// TODO: check a field, maybe CatchupCommitRound?
|
// TODO: check a field, maybe CatchupCommitRound?
|
||||||
|
@ -304,10 +304,10 @@ func (conR *ConsensusReactor) sendNewRoundStepMessage(peer *p2p.Peer) {
|
||||||
rs := conR.conS.GetRoundState()
|
rs := conR.conS.GetRoundState()
|
||||||
nrsMsg, csMsg := makeRoundStepMessages(rs)
|
nrsMsg, csMsg := makeRoundStepMessages(rs)
|
||||||
if nrsMsg != nil {
|
if nrsMsg != nil {
|
||||||
peer.Send(StateChannel, nrsMsg)
|
peer.Send(StateChannel, struct{ ConsensusMessage }{nrsMsg})
|
||||||
}
|
}
|
||||||
if csMsg != nil {
|
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.
|
Round: rs.Round, // This tells peer that this part applies to us.
|
||||||
Part: part,
|
Part: part,
|
||||||
}
|
}
|
||||||
peer.Send(DataChannel, msg)
|
peer.Send(DataChannel, struct{ ConsensusMessage }{msg})
|
||||||
ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
|
ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ OUTER_LOOP:
|
||||||
Round: prs.Round, // Not our height, so it doesn't matter.
|
Round: prs.Round, // Not our height, so it doesn't matter.
|
||||||
Part: part,
|
Part: part,
|
||||||
}
|
}
|
||||||
peer.Send(DataChannel, msg)
|
peer.Send(DataChannel, struct{ ConsensusMessage }{msg})
|
||||||
ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
|
ps.SetHasProposalBlockPart(prs.Height, prs.Round, index)
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
} else {
|
} else {
|
||||||
|
@ -393,7 +393,7 @@ OUTER_LOOP:
|
||||||
// Proposal
|
// Proposal
|
||||||
{
|
{
|
||||||
msg := &ProposalMessage{Proposal: rs.Proposal}
|
msg := &ProposalMessage{Proposal: rs.Proposal}
|
||||||
peer.Send(DataChannel, msg)
|
peer.Send(DataChannel, struct{ ConsensusMessage }{msg})
|
||||||
ps.SetHasProposal(rs.Proposal)
|
ps.SetHasProposal(rs.Proposal)
|
||||||
}
|
}
|
||||||
// ProposalPOL.
|
// ProposalPOL.
|
||||||
|
@ -406,7 +406,7 @@ OUTER_LOOP:
|
||||||
ProposalPOLRound: rs.Proposal.POLRound,
|
ProposalPOLRound: rs.Proposal.POLRound,
|
||||||
ProposalPOL: rs.Votes.Prevotes(rs.Proposal.POLRound).BitArray(),
|
ProposalPOL: rs.Votes.Prevotes(rs.Proposal.POLRound).BitArray(),
|
||||||
}
|
}
|
||||||
peer.Send(DataChannel, msg)
|
peer.Send(DataChannel, struct{ ConsensusMessage }{msg})
|
||||||
}
|
}
|
||||||
continue OUTER_LOOP
|
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) {
|
func (ps *PeerState) PickSendVote(votes types.VoteSetReader) (ok bool) {
|
||||||
if index, vote, ok := ps.PickVoteToSend(votes); ok {
|
if index, vote, ok := ps.PickVoteToSend(votes); ok {
|
||||||
msg := &VoteMessage{index, vote}
|
msg := &VoteMessage{index, vote}
|
||||||
ps.Peer.Send(VoteChannel, msg)
|
ps.Peer.Send(VoteChannel, struct{ ConsensusMessage }{msg})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -123,7 +123,7 @@ func (memR *MempoolReactor) broadcastTxRoutine(peer Peer) {
|
||||||
}
|
}
|
||||||
// send memTx
|
// send memTx
|
||||||
msg := &TxMessage{Tx: memTx.tx}
|
msg := &TxMessage{Tx: memTx.tx}
|
||||||
success := peer.Send(MempoolChannel, msg)
|
success := peer.Send(MempoolChannel, struct{ MempoolMessage }{msg})
|
||||||
if !success {
|
if !success {
|
||||||
time.Sleep(peerCatchupSleepIntervalMS * time.Millisecond)
|
time.Sleep(peerCatchupSleepIntervalMS * time.Millisecond)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -92,7 +92,7 @@ func (app *remoteAppContext) sendRequestsRoutine() {
|
||||||
|
|
||||||
app.willSendReq(reqres)
|
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 {
|
if err != nil {
|
||||||
app.StopForError(err)
|
app.StopForError(err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -17,7 +17,7 @@ var GenDocKey = []byte("GenDocKey")
|
||||||
// core types for a genesis definition
|
// core types for a genesis definition
|
||||||
|
|
||||||
type GenesisValidator struct {
|
type GenesisValidator struct {
|
||||||
PubKey crypto.PubKeyEd25519 `json:"pub_key"`
|
PubKey crypto.PubKey `json:"pub_key"`
|
||||||
Amount int64 `json:"amount"`
|
Amount int64 `json:"amount"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
// every height|round so they don't go in merkle.Tree
|
// every height|round so they don't go in merkle.Tree
|
||||||
type Validator struct {
|
type Validator struct {
|
||||||
Address []byte `json:"address"`
|
Address []byte `json:"address"`
|
||||||
PubKey crypto.PubKeyEd25519 `json:"pub_key"`
|
PubKey crypto.PubKey `json:"pub_key"`
|
||||||
LastCommitHeight int `json:"last_commit_height"`
|
LastCommitHeight int `json:"last_commit_height"`
|
||||||
VotingPower int64 `json:"voting_power"`
|
VotingPower int64 `json:"voting_power"`
|
||||||
Accum int64 `json:"accum"`
|
Accum int64 `json:"accum"`
|
||||||
|
|
Loading…
Reference in New Issue