behaviour

package
v1.7.0-browser Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2023 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

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 is a struct describing a behaviour a peer performed. `peerID` identifies the peer and reason characterizes the specific behaviour performed by the 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 provides an interface for reactors to report the behaviour of peers synchronously to other components.

type SwitchReporter

type SwitchReporter struct {
	// contains filtered or unexported fields
}

SwitchReporter reports peer behaviour to an internal 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL