2025-01-08 17:01:37 -05:00
|
|
|
use core::future::Future;
|
2025-01-03 13:04:27 -05:00
|
|
|
|
2025-01-08 17:01:37 -05:00
|
|
|
use borsh::{BorshSerialize, BorshDeserialize};
|
2025-01-07 18:09:25 -05:00
|
|
|
|
2025-01-08 17:01:37 -05:00
|
|
|
use serai_client::{primitives::NetworkId, validator_sets::primitives::ValidatorSet};
|
2025-01-07 15:36:06 -05:00
|
|
|
|
2025-01-08 17:01:37 -05:00
|
|
|
/// The libp2p-backed P2p network
|
|
|
|
|
mod libp2p;
|
2025-01-03 13:04:27 -05:00
|
|
|
|
2025-01-04 22:21:23 -05:00
|
|
|
/// The heartbeat task, effecting sync of Tributaries
|
2025-01-03 13:04:27 -05:00
|
|
|
mod heartbeat;
|
|
|
|
|
|
2025-01-08 17:01:37 -05:00
|
|
|
/// A tributary block and its commit.
|
|
|
|
|
#[derive(Clone, BorshSerialize, BorshDeserialize)]
|
|
|
|
|
pub(crate) struct TributaryBlockWithCommit {
|
|
|
|
|
pub(crate) block: Vec<u8>,
|
|
|
|
|
pub(crate) commit: Vec<u8>,
|
2025-01-03 13:04:27 -05:00
|
|
|
}
|
2025-01-04 22:21:23 -05:00
|
|
|
|
2025-01-08 17:40:08 -05:00
|
|
|
trait Peer<'a>: Send {
|
2025-01-08 17:01:37 -05:00
|
|
|
fn send_heartbeat(
|
|
|
|
|
&self,
|
|
|
|
|
set: ValidatorSet,
|
|
|
|
|
latest_block_hash: [u8; 32],
|
2025-01-08 17:40:08 -05:00
|
|
|
) -> impl Send + Future<Output = Option<Vec<TributaryBlockWithCommit>>>;
|
2025-01-04 22:21:23 -05:00
|
|
|
}
|
2025-01-04 23:28:29 -05:00
|
|
|
|
2025-01-08 17:01:37 -05:00
|
|
|
trait P2p: Send + Sync + tributary::P2p {
|
2025-01-08 17:40:08 -05:00
|
|
|
type Peer<'a>: Peer<'a>;
|
|
|
|
|
fn peers(&self, network: NetworkId) -> impl Send + Future<Output = Vec<Self::Peer<'_>>>;
|
2025-01-04 23:28:29 -05:00
|
|
|
}
|