Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockReporter ¶
type MockReporter struct {
// contains filtered or unexported fields
}
MockReporter is a concrete implementation of the Reporter interface used in reactor tests to ensure reactors report the correct behaviour in manufactured scenarios.
func NewMockReporter ¶
func NewMockReporter() *MockReporter
NewMockReporter returns a Reporter which records all reported behaviours in memory.
func (*MockReporter) GetBehaviours ¶
func (mpbr *MockReporter) GetBehaviours(peerID p2p.ID) []PeerBehaviour
GetBehaviours returns all behaviours reported on the peer identified by peerID.
func (*MockReporter) Report ¶
func (mpbr *MockReporter) Report(behaviour PeerBehaviour) error
Report stores the PeerBehaviour produced by the peer identified by peerID.
type PeerBehaviour ¶
type PeerBehaviour struct {
// contains filtered or unexported fields
}
PeerBehaviour是一种结构,描述peer执行的行为。 `peerID`表示peer,并且原因表征peer执行的特定行为。
func BadMessage ¶
func BadMessage(peerID p2p.ID, explanation string) PeerBehaviour
BadMessage returns a badMessage PeerBehaviour.
func BlockPart ¶
func BlockPart(peerID p2p.ID, explanation string) PeerBehaviour
BlockPart returns blockPart PeerBehaviour.
func ConsensusVote ¶
func ConsensusVote(peerID p2p.ID, explanation string) PeerBehaviour
ConsensusVote returns a consensusVote PeerBehaviour.
func MessageOutOfOrder ¶
func MessageOutOfOrder(peerID p2p.ID, explanation string) PeerBehaviour
MessageOutOfOrder returns a messagOutOfOrder PeerBehaviour.
type Reporter ¶
type Reporter interface {
Report(behaviour PeerBehaviour) error
}
Reporter为reactor提供了一个接口,可以将peer的行为同步报告给其他组件。
type SwitchReporter ¶
type SwitchReporter struct {
// contains filtered or unexported fields
}
SwitchReporter 将peer的行为报告给内部的switch.
func NewSwitchReporter ¶
func NewSwitchReporter(sw *p2p.Switch) *SwitchReporter
NewSwitchReporter return a new SwitchReporter instance which wraps the Switch.
func (*SwitchReporter) Report ¶
func (spbr *SwitchReporter) Report(behaviour PeerBehaviour) error
Report reports the behaviour of a peer to the Switch.