MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / Report

Method Report

behaviour/reporter.go:29–47  ·  view source on GitHub ↗

Report reports the behaviour of a peer to the Switch.

(behaviour PeerBehaviour)

Source from the content-addressed store, hash-verified

27
28// Report reports the behaviour of a peer to the Switch.
29func (spbr *SwitchReporter) Report(behaviour PeerBehaviour) error {
30 peer := spbr.sw.Peers().Get(behaviour.peerID)
31 if peer == nil {
32 return errors.New("peer not found")
33 }
34
35 switch reason := behaviour.reason.(type) {
36 case consensusVote, blockPart:
37 spbr.sw.MarkPeerAsGood(peer)
38 case badMessage:
39 spbr.sw.StopPeerForError(peer, reason.explanation)
40 case messageOutOfOrder:
41 spbr.sw.StopPeerForError(peer, reason.explanation)
42 default:
43 return errors.New("unknown reason reported")
44 }
45
46 return nil
47}
48
49// MockReporter is a concrete implementation of the Reporter
50// interface used in reactor tests to ensure reactors report the correct

Callers

nothing calls this directly

Calls 4

MarkPeerAsGoodMethod · 0.80
StopPeerForErrorMethod · 0.80
GetMethod · 0.65
PeersMethod · 0.65

Tested by

no test coverage detected