mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Add libp2p module documentation
This commit is contained in:
@@ -1,3 +1,15 @@
|
|||||||
|
//! A libp2p-based backend for P2p.
|
||||||
|
//!
|
||||||
|
//! The libp2p swarm is limited to validators from the Serai network. The swarm does not maintain
|
||||||
|
//! any of its own peer finding/routing infrastructure, instead relying on the Serai network's
|
||||||
|
//! connection information to dial peers. This does limit the listening peers to only the peers
|
||||||
|
//! immediately reachable via the same IP address (despite the two distinct services), not hidden
|
||||||
|
//! behind a NAT, yet is also quite simple and gives full control of who to connect to to us.
|
||||||
|
//!
|
||||||
|
//! Peers are decided via the `DialTask` which aims to maintain a target amount of peers from each
|
||||||
|
//! external network.
|
||||||
|
// TODO: Consider adding that infrastructure, leaving the Serai network solely for bootstrapping
|
||||||
|
|
||||||
use core::{future::Future, time::Duration};
|
use core::{future::Future, time::Duration};
|
||||||
use std::{
|
use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@@ -113,10 +125,15 @@ struct Peers {
|
|||||||
|
|
||||||
#[derive(NetworkBehaviour)]
|
#[derive(NetworkBehaviour)]
|
||||||
struct Behavior {
|
struct Behavior {
|
||||||
|
// Used to only allow Serai validators as peers
|
||||||
allow_list: allow_block_list::Behaviour<allow_block_list::AllowedPeers>,
|
allow_list: allow_block_list::Behaviour<allow_block_list::AllowedPeers>,
|
||||||
|
// Used to limit each peer to a single connection
|
||||||
connection_limits: connection_limits::Behaviour,
|
connection_limits: connection_limits::Behaviour,
|
||||||
|
// Used to ensure connection latency is within tolerances
|
||||||
ping: ping::Behavior,
|
ping: ping::Behavior,
|
||||||
|
// Used to request data from specific peers
|
||||||
reqres: reqres::Behavior,
|
reqres: reqres::Behavior,
|
||||||
|
// Used to broadcast messages to all other peers subscribed to a topic
|
||||||
gossip: gossip::Behavior,
|
gossip: gossip::Behavior,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use tokio::sync::oneshot;
|
|||||||
|
|
||||||
use serai_cosign::SignedCosign;
|
use serai_cosign::SignedCosign;
|
||||||
|
|
||||||
/// The libp2p-backed P2p network
|
/// The libp2p-backed P2P network
|
||||||
mod libp2p;
|
mod libp2p;
|
||||||
|
|
||||||
/// The heartbeat task, effecting sync of Tributaries
|
/// The heartbeat task, effecting sync of Tributaries
|
||||||
|
|||||||
Reference in New Issue
Block a user