mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 22:05:18 +00:00
Receive called from OnReceive
This commit is contained in:
@@ -38,9 +38,25 @@ type Reactor interface {
|
||||
// or other reason).
|
||||
RemovePeer(peer Peer, reason interface{})
|
||||
|
||||
// Receive is called by the switch when an envelope is received from any connected
|
||||
// NewReceive is called by the switch when an envelope is received from any connected
|
||||
// peer on any of the channels registered by the reactor
|
||||
//
|
||||
// The set of messages passed to Receive and NewReceive are identical. While both
|
||||
// need to be implemented to satisfy the interface, only one message stream
|
||||
// should be used per reactor.
|
||||
NewReceive(Envelope)
|
||||
|
||||
// Receive is called by the switch when msgBytes is received from the peer.
|
||||
//
|
||||
// NOTE reactor can not keep msgBytes around after Receive completes without
|
||||
// copying.
|
||||
//
|
||||
// CONTRACT: msgBytes are not nil.
|
||||
//
|
||||
// The messages passed to Receive and NewReceive are identical. While both
|
||||
// need to be implemented to satisfy the interface, only one message stream
|
||||
// should be used per reactor.
|
||||
Receive(chID byte, peer Peer, msgBytes []byte)
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
@@ -60,8 +76,9 @@ func NewBaseReactor(name string, impl Reactor) *BaseReactor {
|
||||
func (br *BaseReactor) SetSwitch(sw *Switch) {
|
||||
br.Switch = sw
|
||||
}
|
||||
func (*BaseReactor) GetChannels() []*conn.ChannelDescriptor { return nil }
|
||||
func (*BaseReactor) AddPeer(peer Peer) {}
|
||||
func (*BaseReactor) RemovePeer(peer Peer, reason interface{}) {}
|
||||
func (*BaseReactor) NewReceive(e Envelope) {}
|
||||
func (*BaseReactor) InitPeer(peer Peer) Peer { return peer }
|
||||
func (*BaseReactor) GetChannels() []*conn.ChannelDescriptor { return nil }
|
||||
func (*BaseReactor) AddPeer(peer Peer) {}
|
||||
func (*BaseReactor) RemovePeer(peer Peer, reason interface{}) {}
|
||||
func (*BaseReactor) NewReceive(e Envelope) {}
|
||||
func (*BaseReactor) Receive(chID byte, peer Peer, msgBytes []byte) {}
|
||||
func (*BaseReactor) InitPeer(peer Peer) Peer { return peer }
|
||||
|
||||
@@ -482,6 +482,7 @@ func createMConnection(
|
||||
Src: p,
|
||||
Message: msg,
|
||||
})
|
||||
reactor.Receive(chID, p, msgBytes)
|
||||
}
|
||||
|
||||
onError := func(r interface{}) {
|
||||
|
||||
Reference in New Issue
Block a user