ProposalMessage wrapper, warn on unknown messages
This commit is contained in:
parent
dc27d56cc3
commit
5b1c1eb0e0
|
@ -270,6 +270,7 @@ func DecodeMessage(bz []byte) (msgType byte, msg interface{}, err error) {
|
|||
case msgTypePeerStatus:
|
||||
msg = binary.ReadBinary(bcPeerStatusMessage{}, r, n, &err)
|
||||
default:
|
||||
log.Warn(Fmt("Ignoring unknown message %X", bz))
|
||||
msg = nil
|
||||
}
|
||||
return
|
||||
|
|
|
@ -152,9 +152,9 @@ func (conR *ConsensusReactor) Receive(chId byte, peer *p2p.Peer, msgBytes []byte
|
|||
|
||||
case DataChannel:
|
||||
switch msg := msg_.(type) {
|
||||
case *Proposal:
|
||||
ps.SetHasProposal(msg)
|
||||
err = conR.conS.SetProposal(msg)
|
||||
case *ProposalMessage:
|
||||
ps.SetHasProposal(msg.Proposal)
|
||||
err = conR.conS.SetProposal(msg.Proposal)
|
||||
|
||||
case *PartMessage:
|
||||
if msg.Type == partTypeProposalBlock {
|
||||
|
@ -374,7 +374,7 @@ OUTER_LOOP:
|
|||
|
||||
// Send proposal?
|
||||
if rs.Proposal != nil && !prs.Proposal {
|
||||
msg := p2p.TypedMessage{msgTypeProposal, rs.Proposal}
|
||||
msg := &ProposalMessage{Proposal: rs.Proposal}
|
||||
peer.Send(DataChannel, msg)
|
||||
ps.SetHasProposal(rs.Proposal)
|
||||
continue OUTER_LOOP
|
||||
|
@ -777,8 +777,7 @@ func DecodeMessage(bz []byte) (msgType byte, msg interface{}, err error) {
|
|||
msg = binary.ReadBinary(&CommitStepMessage{}, r, n, &err)
|
||||
// Messages of data
|
||||
case msgTypeProposal:
|
||||
r.ReadByte() // Consume the byte
|
||||
msg = binary.ReadBinary(&Proposal{}, r, n, &err)
|
||||
msg = binary.ReadBinary(&ProposalMessage{}, r, n, &err)
|
||||
case msgTypePart:
|
||||
msg = binary.ReadBinary(&PartMessage{}, r, n, &err)
|
||||
case msgTypeVote:
|
||||
|
@ -786,6 +785,7 @@ func DecodeMessage(bz []byte) (msgType byte, msg interface{}, err error) {
|
|||
case msgTypeHasVote:
|
||||
msg = binary.ReadBinary(&HasVoteMessage{}, r, n, &err)
|
||||
default:
|
||||
log.Warn(Fmt("Ignoring unknown message %X", bz))
|
||||
msg = nil
|
||||
}
|
||||
return
|
||||
|
@ -822,6 +822,18 @@ func (m *CommitStepMessage) String() string {
|
|||
|
||||
//-------------------------------------
|
||||
|
||||
type ProposalMessage struct {
|
||||
Proposal *Proposal
|
||||
}
|
||||
|
||||
func (m *ProposalMessage) TypeByte() byte { return msgTypeProposal }
|
||||
|
||||
func (m *ProposalMessage) String() string {
|
||||
return fmt.Sprintf("[Proposal %v]", m.Proposal)
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
const (
|
||||
partTypeProposalBlock = byte(0x01)
|
||||
partTypeProposalPOL = byte(0x02)
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"sync/atomic"
|
||||
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/events"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
@ -135,6 +136,7 @@ func DecodeMessage(bz []byte) (msgType byte, msg interface{}, err error) {
|
|||
case msgTypeTx:
|
||||
msg = binary.ReadBinary(&TxMessage{}, r, n, &err)
|
||||
default:
|
||||
log.Warn(Fmt("Ignoring unknown message %X", bz))
|
||||
msg = nil
|
||||
}
|
||||
return
|
||||
|
|
|
@ -239,6 +239,7 @@ func DecodeMessage(bz []byte) (msg interface{}, err error) {
|
|||
case msgTypeAddrs:
|
||||
msg = binary.ReadBinary(&pexAddrsMessage{}, r, n, &err)
|
||||
default:
|
||||
log.Warn(Fmt("Ignoring unknown message %X", bz))
|
||||
msg = nil
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue