Report reports the behaviour of a peer to the Switch.
(behaviour PeerBehaviour)
| 27 | |
| 28 | // Report reports the behaviour of a peer to the Switch. |
| 29 | func (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 |
nothing calls this directly
no test coverage detected