Browse Source

Fixed BlockchainMessage{} Decode issue.

Fixed Warn(UnknownMessage) issues.
pull/55/head
Jae Kwon 10 years ago
parent
commit
44565872ae
4 changed files with 11 additions and 11 deletions
  1. +3
    -3
      blockchain/reactor.go
  2. +5
    -6
      consensus/reactor.go
  3. +2
    -1
      mempool/reactor.go
  4. +1
    -1
      p2p/pex_reactor.go

+ 3
- 3
blockchain/reactor.go View File

@ -145,7 +145,7 @@ func (bcR *BlockchainReactor) Receive(chId byte, src *p2p.Peer, msgBytes []byte)
// Got a peer status.
bcR.pool.SetPeerHeight(src.Key, msg.Height)
default:
log.Warn("Unknown message type %v", reflect.TypeOf(msg))
log.Warn(Fmt("Unknown message type %v", reflect.TypeOf(msg)))
}
}
@ -270,7 +270,7 @@ func DecodeMessage(bz []byte) (msgType byte, msg BlockchainMessage, err error) {
msgType = bz[0]
n := new(int64)
r := bytes.NewReader(bz)
msg = binary.ReadBinary(&msg, r, n, &err)
msg = binary.ReadBinary(struct{ BlockchainMessage }{}, r, n, &err).(struct{ BlockchainMessage }).BlockchainMessage
return
}
@ -300,6 +300,6 @@ type bcPeerStatusMessage struct {
Height uint
}
func (m bcPeerStatusMessage) String() string {
func (m *bcPeerStatusMessage) String() string {
return fmt.Sprintf("[bcPeerStatusMessage %v]", m.Height)
}

+ 5
- 6
consensus/reactor.go View File

@ -148,7 +148,7 @@ func (conR *ConsensusReactor) Receive(chId byte, peer *p2p.Peer, msgBytes []byte
case *HasVoteMessage:
ps.ApplyHasVoteMessage(msg)
default:
log.Warn("Unknown message type %v", reflect.TypeOf(msg))
log.Warn(Fmt("Unknown message type %v", reflect.TypeOf(msg)))
}
case DataChannel:
@ -165,11 +165,11 @@ func (conR *ConsensusReactor) Receive(chId byte, peer *p2p.Peer, msgBytes []byte
ps.SetHasProposalPOLPart(msg.Height, msg.Round, msg.Part.Index)
_, err = conR.conS.AddProposalPOLPart(msg.Height, msg.Round, msg.Part)
} else {
log.Warn("Unknown part type %v", msg.Type)
log.Warn(Fmt("Unknown part type %v", msg.Type))
}
default:
log.Warn("Unknown message type %v", reflect.TypeOf(msg))
log.Warn(Fmt("Unknown message type %v", reflect.TypeOf(msg)))
}
case VoteChannel:
@ -213,10 +213,10 @@ func (conR *ConsensusReactor) Receive(chId byte, peer *p2p.Peer, msgBytes []byte
}
default:
log.Warn("Unknown message type %v", reflect.TypeOf(msg))
log.Warn(Fmt("Unknown message type %v", reflect.TypeOf(msg)))
}
default:
log.Warn("Unknown channel %X", chId)
log.Warn(Fmt("Unknown channel %X", chId))
}
if err != nil {
@ -755,7 +755,6 @@ func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage) {
// Messages
const (
msgTypeUnknown = byte(0x00)
msgTypeNewRoundStep = byte(0x01)
msgTypeCommitStep = byte(0x02)
msgTypeProposal = byte(0x11)


+ 2
- 1
mempool/reactor.go View File

@ -7,6 +7,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"
@ -100,7 +101,7 @@ func (memR *MempoolReactor) Receive(chId byte, src *p2p.Peer, msgBytes []byte) {
}
default:
log.Warn("Unknown message type %v", reflect.TypeOf(msg))
log.Warn(Fmt("Unknown message type %v", reflect.TypeOf(msg)))
}
}


+ 1
- 1
p2p/pex_reactor.go View File

@ -120,7 +120,7 @@ func (pexR *PEXReactor) Receive(chId byte, src *Peer, msgBytes []byte) {
pexR.book.AddAddress(addr, srcAddr)
}
default:
log.Warn("Unknown message type %v", reflect.TypeOf(msg))
log.Warn(Fmt("Unknown message type %v", reflect.TypeOf(msg)))
}
}


Loading…
Cancel
Save