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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
pub mod addr_manager;
pub mod ban_list;
mod peer_id_serde;
mod peer_store_db;
mod peer_store_impl;
pub mod types;
pub use crate::SessionType;
pub(crate) use crate::{Behaviour, PeerId};
use p2p::multiaddr::Multiaddr;
pub use peer_store_impl::PeerStore;
pub(crate) const ADDR_COUNT_LIMIT: usize = 16384;
const ADDR_TIMEOUT_MS: u64 = 7 * 24 * 3600 * 1000;
const ADDR_MAX_RETRIES: u32 = 3;
const ADDR_MAX_FAILURES: u32 = 10;
pub type Score = i32;
#[derive(Copy, Clone, Debug)]
pub struct PeerScoreConfig {
pub default_score: Score,
pub ban_score: Score,
pub ban_timeout_ms: u64,
}
impl Default for PeerScoreConfig {
fn default() -> Self {
PeerScoreConfig {
default_score: 100,
ban_score: 40,
ban_timeout_ms: 24 * 3600 * 1000,
}
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Status {
Connected,
Disconnected,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum ReportResult {
Ok,
Banned,
}
impl ReportResult {
pub fn is_banned(self) -> bool {
self == ReportResult::Banned
}
pub fn is_ok(self) -> bool {
self == ReportResult::Ok
}
}