pub struct Backend {
config: Arc<Config>,
key_pair: KeyPair,
peer_id: PeerID,
monitor: Arc<Monitor>,
discovery: Arc<Discovery>,
peer_pool: Arc<PeerPool>,
}
Expand description
Backend serves as the central entry point for initiating and managing the P2P network.
Fields§
§config: Arc<Config>
The Configuration for the P2P network.
key_pair: KeyPair
Identity Key pair
peer_id: PeerID
Peer ID
monitor: Arc<Monitor>
Responsible for network and system monitoring.
discovery: Arc<Discovery>
Discovery instance.
peer_pool: Arc<PeerPool>
PeerPool instance.
Implementations§
Source§impl Backend
impl Backend
Sourcepub fn new(key_pair: &KeyPair, config: Config, ex: Executor) -> Arc<Backend>
pub fn new(key_pair: &KeyPair, config: Config, ex: Executor) -> Arc<Backend>
Creates a new Backend.
Sourcepub async fn run(self: &Arc<Self>) -> Result<()>
pub async fn run(self: &Arc<Self>) -> Result<()>
Run the Backend, starting the PeerPool and Discovery instances.
Sourcepub async fn attach_protocol<P: Protocol>(
&self,
c: impl Fn(Arc<Peer>) -> Arc<dyn Protocol> + Send + Sync + 'static,
) -> Result<()>
pub async fn attach_protocol<P: Protocol>( &self, c: impl Fn(Arc<Peer>) -> Arc<dyn Protocol> + Send + Sync + 'static, ) -> Result<()>
Attach a custom protocol to the network
Sourcepub async fn inbound_peers(&self) -> HashMap<PeerID, Endpoint>
pub async fn inbound_peers(&self) -> HashMap<PeerID, Endpoint>
Returns a map of inbound connected peers with their endpoints.
Sourcepub async fn outbound_peers(&self) -> HashMap<PeerID, Endpoint>
pub async fn outbound_peers(&self) -> HashMap<PeerID, Endpoint>
Returns a map of outbound connected peers with their endpoints.
Auto Trait Implementations§
impl Freeze for Backend
impl !RefUnwindSafe for Backend
impl Send for Backend
impl Sync for Backend
impl Unpin for Backend
impl !UnwindSafe for Backend
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more