fedimint_server/consensus/aleph_bft/
mod.rs

1pub mod backup;
2pub mod data_provider;
3pub mod finalization_handler;
4pub mod keychain;
5pub mod network;
6pub mod spawner;
7
8use aleph_bft::NodeIndex;
9use fedimint_core::encoding::{Decodable, Encodable};
10use fedimint_core::PeerId;
11use serde::{Deserialize, Serialize};
12
13/// The majority of these messages need to be delivered to the intended
14/// recipient for Aleph BFT to make progress. However, Aleph BFT does
15/// not assume a reliable network layer and implements all necessary retry
16/// logic. Therefore, the network layer can discard a message if its
17/// intended recipient is offline.
18#[derive(Clone, Debug, Encodable, Decodable, Serialize, Deserialize)]
19pub struct Message(Vec<u8>);
20
21pub fn to_peer_id(node_index: NodeIndex) -> PeerId {
22    u16::try_from(usize::from(node_index))
23        .expect("The node index corresponds to a valid PeerId")
24        .into()
25}
26
27pub fn to_node_index(peer_id: PeerId) -> NodeIndex {
28    usize::from(u16::from(peer_id)).into()
29}