github.com/DFWallet/tendermint-cosmos@v0.0.2/behaviour/peer_behaviour.go (about) 1 package behaviour 2 3 import ( 4 "github.com/DFWallet/tendermint-cosmos/p2p" 5 ) 6 7 // PeerBehaviour is a struct describing a behaviour a peer performed. 8 // `peerID` identifies the peer and reason characterizes the specific 9 // behaviour performed by the peer. 10 type PeerBehaviour struct { 11 peerID p2p.ID 12 reason interface{} 13 } 14 15 type badMessage struct { 16 explanation string 17 } 18 19 // BadMessage returns a badMessage PeerBehaviour. 20 func BadMessage(peerID p2p.ID, explanation string) PeerBehaviour { 21 return PeerBehaviour{peerID: peerID, reason: badMessage{explanation}} 22 } 23 24 type messageOutOfOrder struct { 25 explanation string 26 } 27 28 // MessageOutOfOrder returns a messagOutOfOrder PeerBehaviour. 29 func MessageOutOfOrder(peerID p2p.ID, explanation string) PeerBehaviour { 30 return PeerBehaviour{peerID: peerID, reason: messageOutOfOrder{explanation}} 31 } 32 33 type consensusVote struct { 34 explanation string 35 } 36 37 // ConsensusVote returns a consensusVote PeerBehaviour. 38 func ConsensusVote(peerID p2p.ID, explanation string) PeerBehaviour { 39 return PeerBehaviour{peerID: peerID, reason: consensusVote{explanation}} 40 } 41 42 type blockPart struct { 43 explanation string 44 } 45 46 // BlockPart returns blockPart PeerBehaviour. 47 func BlockPart(peerID p2p.ID, explanation string) PeerBehaviour { 48 return PeerBehaviour{peerID: peerID, reason: blockPart{explanation}} 49 }