ckb_network/
behaviour.rs

1use crate::Score;
2
3/// Peers behaviours
4/// we maintain a score to each peer
5/// report peer behaviour will affects peer's score
6///
7/// Currently this feature is disabled, maybe someday we will add it back or totally remove it.
8#[derive(Debug, Clone, Copy, Eq, PartialEq)]
9pub enum Behaviour {
10    /// Good behaviour
11    #[cfg(test)]
12    TestGood,
13    /// Bad behaviour
14    #[cfg(test)]
15    TestBad,
16}
17
18impl Behaviour {
19    /// Behaviour score
20    pub fn score(self) -> Score {
21        #[cfg(test)]
22        match self {
23            Behaviour::TestGood => 10,
24            Behaviour::TestBad => -10,
25        }
26        #[cfg(not(test))]
27        0
28    }
29}