Struct lumina_node::p2p::P2p
source · pub struct P2p<S>where
S: Store + 'static,{ /* private fields */ }Expand description
Component responsible for the peer to peer networking handling.
Implementations§
source§impl<S> P2p<S>where
S: Store,
impl<S> P2p<S>where
S: Store,
sourcepub fn mocked() -> (Self, MockP2pHandle)
pub fn mocked() -> (Self, MockP2pHandle)
Creates and starts a new mocked p2p handler.
sourcepub fn local_peer_id(&self) -> &PeerId
pub fn local_peer_id(&self) -> &PeerId
Local peer ID on the p2p network.
sourcepub fn header_sub_watcher(&self) -> Receiver<Option<ExtendedHeader>>
pub fn header_sub_watcher(&self) -> Receiver<Option<ExtendedHeader>>
Watcher for the latest verified network head headers announced on header-sub.
sourcepub fn peer_tracker_info_watcher(&self) -> Receiver<PeerTrackerInfo>
pub fn peer_tracker_info_watcher(&self) -> Receiver<PeerTrackerInfo>
Watcher for the current PeerTrackerInfo.
sourcepub fn peer_tracker_info(&self) -> Ref<'_, PeerTrackerInfo>
pub fn peer_tracker_info(&self) -> Ref<'_, PeerTrackerInfo>
A reference to the current PeerTrackerInfo.
sourcepub async fn init_header_sub(
&self,
head: ExtendedHeader
) -> Result<(), P2pError>
pub async fn init_header_sub( &self, head: ExtendedHeader ) -> Result<(), P2pError>
Initializes header-sub protocol with a given subjective_head.
sourcepub async fn wait_connected(&self) -> Result<(), P2pError>
pub async fn wait_connected(&self) -> Result<(), P2pError>
Wait until the node is connected to any peer.
sourcepub async fn wait_connected_trusted(&self) -> Result<(), P2pError>
pub async fn wait_connected_trusted(&self) -> Result<(), P2pError>
Wait until the node is connected to any trusted peer.
sourcepub async fn network_info(&self) -> Result<NetworkInfo, P2pError>
pub async fn network_info(&self) -> Result<NetworkInfo, P2pError>
Get current [NetworkInfo].
sourcepub async fn header_ex_request(
&self,
request: HeaderRequest
) -> Result<Vec<ExtendedHeader>, P2pError>
pub async fn header_ex_request( &self, request: HeaderRequest ) -> Result<Vec<ExtendedHeader>, P2pError>
Send a request on the header-ex protocol.
sourcepub async fn get_head_header(&self) -> Result<ExtendedHeader, P2pError>
pub async fn get_head_header(&self) -> Result<ExtendedHeader, P2pError>
Request the head header on the header-ex protocol.
sourcepub async fn get_header(&self, hash: Hash) -> Result<ExtendedHeader, P2pError>
pub async fn get_header(&self, hash: Hash) -> Result<ExtendedHeader, P2pError>
Request the header by hash on the header-ex protocol.
sourcepub async fn get_header_by_height(
&self,
height: u64
) -> Result<ExtendedHeader, P2pError>
pub async fn get_header_by_height( &self, height: u64 ) -> Result<ExtendedHeader, P2pError>
Request the header by height on the header-ex protocol.
sourcepub async fn get_verified_headers_range(
&self,
from: &ExtendedHeader,
amount: u64
) -> Result<Vec<ExtendedHeader>, P2pError>
pub async fn get_verified_headers_range( &self, from: &ExtendedHeader, amount: u64 ) -> Result<Vec<ExtendedHeader>, P2pError>
Request the headers following the one given with the header-ex protocol.
First header from the requested range will be verified against the provided one, then each subsequent is verified against the previous one.
sourcepub async fn listeners(&self) -> Result<Vec<Multiaddr>, P2pError>
pub async fn listeners(&self) -> Result<Vec<Multiaddr>, P2pError>
Get the addresses where P2p listens on for incoming connections.
sourcepub async fn connected_peers(&self) -> Result<Vec<PeerId>, P2pError>
pub async fn connected_peers(&self) -> Result<Vec<PeerId>, P2pError>
Get the list of connected peers.