1
0
mirror of https://github.com/fluencelabs/tendermint synced 2025-07-29 19:21:56 +00:00
Files
.circleci
.github
DOCKER
abci
benchmarks
blockchain
cmd
config
consensus
crypto
docs
evidence
libs
lite
mempool
networks
node
p2p
conn
dummy
pex
trust
upnp
README.md
base_reactor.go
errors.go
fuzz.go
key.go
key_test.go
listener.go
listener_test.go
metrics.go
netaddress.go
netaddress_test.go
node_info.go
peer.go
peer_set.go
peer_set_test.go
peer_test.go
switch.go
switch_test.go
test_util.go
types.go
version.go
wire.go
privval
proxy
rpc
scripts
state
test
tools
types
version
.editorconfig
.gitignore
CHANGELOG.md
CHANGELOG_PENDING.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md
ROADMAP.md
SECURITY.md
Vagrantfile
appveyor.yml
codecov.yml
docker-compose.yml
tendermint/p2p/base_reactor.go

54 lines
1.4 KiB
Go
Raw Normal View History

2018-01-13 17:25:51 -05:00
package p2p
2018-01-20 21:12:04 -05:00
import (
2018-07-01 22:36:49 -04:00
cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/p2p/conn"
2018-01-20 21:12:04 -05:00
)
2018-01-13 17:25:51 -05:00
type Reactor interface {
cmn.Service // Start, Stop
2018-02-08 13:07:40 +04:00
// SetSwitch allows setting a switch.
2018-01-13 17:25:51 -05:00
SetSwitch(*Switch)
2018-02-08 13:07:40 +04:00
// GetChannels returns the list of channel descriptors.
2018-01-21 00:33:53 -05:00
GetChannels() []*conn.ChannelDescriptor
2018-02-08 13:07:40 +04:00
// AddPeer is called by the switch when a new peer is added.
2018-01-13 17:25:51 -05:00
AddPeer(peer Peer)
2018-02-08 13:07:40 +04:00
// RemovePeer is called by the switch when the peer is stopped (due to error
// or other reason).
2018-01-13 17:25:51 -05:00
RemovePeer(peer Peer, reason interface{})
2018-02-08 13:07:40 +04:00
// Receive is called when msgBytes is received from peer.
//
// NOTE reactor can not keep msgBytes around after Receive completes without
// copying.
//
// CONTRACT: msgBytes are not nil.
2018-02-08 13:07:40 +04:00
Receive(chID byte, peer Peer, msgBytes []byte)
2018-01-13 17:25:51 -05:00
}
//--------------------------------------
type BaseReactor struct {
cmn.BaseService // Provides Start, Stop, .Quit
Switch *Switch
}
func NewBaseReactor(name string, impl Reactor) *BaseReactor {
return &BaseReactor{
BaseService: *cmn.NewBaseService(nil, name, impl),
Switch: nil,
}
}
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) Receive(chID byte, peer Peer, msgBytes []byte) {}