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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! # Eigen Trust
//!
//! A library for managing trust in a distributed network with zero-knowledge
//! features.
//!
//! ## Main characteristics:
//! **Self-policing** - the shared ethics of the user population is defined and
//! enforced by the peers themselves and not by some central authority.
//!
//! **Minimal** - computation, infrastructure, storage, and message complexity
//! are reduced to a minimum.
//!
//! **Incorruptible** - Reputation should be obtained by consistent good
//! behavior through several transactions. This is enforced for all users, so no
//! one can cheat the system and obtain a higher reputation. It is also
//! resistant to malicious collectives.
//!
//! ## Usage:
//! ```rust
//! use eigen_trust::{EigenError, Keypair, LevelFilter, Multiaddr, Node, NodeConfig, PeerId};
//! use std::str::FromStr;
//!
//! const BOOTSTRAP_PEERS: [(&str, &str, f64); 2] = [
//! (
//! "/ip4/127.0.0.1/tcp/58584",
//! "12D3KooWLyTCx9j2FMcsHe81RMoDfhXbdyyFgNGQMdcrnhShTvQh",
//! 0.5,
//! ),
//! (
//! "/ip4/127.0.0.1/tcp/58601",
//! "12D3KooWKBKXsLwbmVBySEmbKayJzfWp3tPCKrnDCsmNy9prwjvy",
//! 0.5,
//! ),
//! ];
//!
//! const DEFAULT_ADDRESS: &str = "/ip4/0.0.0.0/tcp/0";
//!
//! struct Config;
//! impl NodeConfig for Config {
//! const INTERVAL: u64 = 2;
//! const NUM_CONNECTIONS: usize = 12;
//! const PRE_TRUST_WEIGHT: f64 = 0.2;
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<(), EigenError> {
//! let local_key = Keypair::generate_ed25519();
//! let local_address =
//! Multiaddr::from_str(DEFAULT_ADDRESS).map_err(|_| EigenError::InvalidAddress)?;
//!
//! let mut bootstrap_nodes = Vec::new();
//! for info in BOOTSTRAP_PEERS.iter() {
//! let peer_addr = Multiaddr::from_str(info.0).map_err(|_| EigenError::InvalidAddress)?;
//! let peer_id = PeerId::from_str(info.1).map_err(|_| EigenError::InvalidPeerId)?;
//!
//! bootstrap_nodes.push((peer_id, peer_addr, info.2));
//! }
//!
//! let node = Node::<Config>::new(local_key, local_address, bootstrap_nodes)?;
//! node.main_loop(Some(1)).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Implementation
//! The library is implemented according to the original [Eigen Trust paper](http://ilpubs.stanford.edu:8090/562/1/2002-56.pdf).
//! It is developed under the Ethereum Foundation grant.
/// The module for epoch-related calculations, like seconds until the next
/// epoch, current epoch, etc.
/// The module for the node setup, running the main loop, and handling network
/// events.
/// The module for the peer related functionalities, like:
/// - Adding/removing neighbors
/// - Calculating the global trust score
/// - Calculating local scores toward neighbors for a given epoch
/// - Keeping track of neighbors scores towards us
/// The module for defining the request-response protocol.
pub use Epoch;
pub use ;
pub use LevelFilter;
pub use ;
pub use Peer;
/// The crate-wide error variants.