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
use codec::{Decode, Encode};
use futures::{channel::mpsc, Future};
use std::{fmt::Debug, hash::Hash as StdHash, pin::Pin};
use crate::nodes::NodeMap;
pub use config::{default_config, exponential_slowdown, Config, DelayConfig};
pub use member::run_session;
pub use network::{Network, NetworkData, Recipient};
pub use nodes::{NodeCount, NodeIndex};
mod alerts;
mod consensus;
mod creation;
mod extender;
mod member;
mod network;
mod nodes;
mod runway;
mod signed;
pub use signed::*;
mod config;
pub mod rmc;
mod terminal;
#[cfg(test)]
pub mod testing;
mod units;
pub type SessionId = u64;
pub trait DataIO<Data> {
type Error: Debug + 'static;
fn get_data(&self) -> Data;
fn send_ordered_batch(&mut self, data: OrderedBatch<Data>) -> Result<(), Self::Error>;
}
pub trait Index {
fn index(&self) -> NodeIndex;
}
pub trait Hasher: Eq + Clone + Send + Sync + Debug + 'static {
type Hash: AsRef<[u8]>
+ Eq
+ Ord
+ Copy
+ Clone
+ Send
+ Sync
+ Debug
+ StdHash
+ Encode
+ Decode;
fn hash(s: &[u8]) -> Self::Hash;
}
pub trait Data: Eq + Clone + Send + Sync + Debug + StdHash + Encode + Decode + 'static {}
impl<T> Data for T where T: Eq + Clone + Send + Sync + Debug + StdHash + Encode + Decode + 'static {}
pub type Round = u16;
pub type OrderedBatch<Data> = Vec<Data>;
pub type TaskHandle = Pin<Box<dyn Future<Output = Result<(), ()>> + Send>>;
pub trait SpawnHandle: Clone + Send + 'static {
fn spawn(&self, name: &'static str, task: impl Future<Output = ()> + Send + 'static);
fn spawn_essential(
&self,
name: &'static str,
task: impl Future<Output = ()> + Send + 'static,
) -> TaskHandle;
}
pub(crate) type Receiver<T> = mpsc::UnboundedReceiver<T>;
pub(crate) type Sender<T> = mpsc::UnboundedSender<T>;