aleph_bft_types/
lib.rs

1//! Traits that need to be implemented by the user.
2
3mod dataio;
4mod network;
5mod tasks;
6
7pub use aleph_bft_crypto::{
8    IncompleteMultisignatureError, Index, Indexed, Keychain, MultiKeychain, Multisigned, NodeCount,
9    NodeIndex, NodeMap, NodeSubset, PartialMultisignature, PartiallyMultisigned, Signable,
10    Signature, SignatureError, SignatureSet, Signed, UncheckedSigned,
11};
12pub use dataio::{DataProvider, FinalizationHandler, OrderedUnit, UnitFinalizationHandler};
13pub use network::{Network, Recipient};
14pub use tasks::{SpawnHandle, TaskHandle};
15
16use codec::Codec;
17use std::{fmt::Debug, hash::Hash as StdHash};
18
19/// Data type that we want to order.
20pub trait Data: Eq + Clone + Send + Sync + Debug + StdHash + Codec + 'static {}
21
22impl<T> Data for T where T: Eq + Clone + Send + Sync + Debug + StdHash + Codec + 'static {}
23
24/// A hasher, used for creating identifiers for blocks or units.
25pub trait Hasher: Eq + Clone + Send + Sync + Debug + 'static {
26    /// A hash, as an identifier for a block or unit.
27    type Hash: AsRef<[u8]> + Eq + Ord + Copy + Clone + Send + Sync + Debug + StdHash + Codec;
28
29    fn hash(s: &[u8]) -> Self::Hash;
30}
31
32/// The number of a session for which the consensus is run.
33pub type SessionId = u64;
34
35/// An asynchronous round of the protocol.
36pub type Round = u16;