Browse Source

Conform to go-wire new TypeByte behavior

pull/171/head
Jae Kwon 9 years ago
parent
commit
08d7980d80
6 changed files with 22 additions and 22 deletions
  1. +4
    -4
      blockchain/reactor.go
  2. +8
    -8
      consensus/reactor.go
  3. +1
    -1
      mempool/reactor.go
  4. +1
    -1
      proxy/remote_app_context.go
  5. +3
    -3
      types/genesis.go
  6. +5
    -5
      types/validator.go

+ 4
- 4
blockchain/reactor.go View File

@ -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.


+ 8
- 8
consensus/reactor.go View File

@ -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


+ 1
- 1
mempool/reactor.go View File

@ -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


+ 1
- 1
proxy/remote_app_context.go View File

@ -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


+ 3
- 3
types/genesis.go View File

@ -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 {


+ 5
- 5
types/validator.go View File

@ -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.


Loading…
Cancel
Save