1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::Score;

/// Peers behaviours
/// we maintain a score to each peer
/// report peer bahaviour will affects peer's score
///
/// Currently this feature is disabled, maybe someday we will add it back or totally remove it.
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum Behaviour {
    #[cfg(test)]
    TestGood,
    #[cfg(test)]
    TestBad,
}

impl Behaviour {
    /// Behaviour score
    pub fn score(self) -> Score {
        #[cfg(test)]
        match self {
            Behaviour::TestGood => 10,
            Behaviour::TestBad => -10,
        }
        #[cfg(not(test))]
        0
    }
}