Struct lumina_node::p2p::P2p
source · pub struct P2p { /* private fields */ }Expand description
Component responsible for the peer to peer networking handling.
Implementations§
source§impl P2p
impl P2p
sourcepub fn start<B, S>(args: P2pArgs<B, S>) -> Result<Self, P2pError>where
B: Blockstore + 'static,
S: Store + 'static,
pub fn start<B, S>(args: P2pArgs<B, S>) -> Result<Self, P2pError>where
B: Blockstore + 'static,
S: Store + 'static,
Creates and starts a new p2p handler.
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 get_row(
&self,
row_index: u16,
block_height: u64
) -> Result<Row, P2pError>
pub async fn get_row( &self, row_index: u16, block_height: u64 ) -> Result<Row, P2pError>
Request a Row on bitswap protocol.
sourcepub async fn get_sample(
&self,
row_index: u16,
column_index: u16,
block_height: u64
) -> Result<Sample, P2pError>
pub async fn get_sample( &self, row_index: u16, column_index: u16, block_height: u64 ) -> Result<Sample, P2pError>
Request a Sample on bitswap protocol.
This method awaits for a verified Sample until timeout of 10 second
is reached. On timeout it is safe to assume that sampling of the block
failed.
sourcepub async fn get_namespaced_data(
&self,
namespace: Namespace,
row_index: u16,
block_height: u64
) -> Result<NamespacedData, P2pError>
pub async fn get_namespaced_data( &self, namespace: Namespace, row_index: u16, block_height: u64 ) -> Result<NamespacedData, P2pError>
Request a NamespacedData on bitswap protocol.
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for P2p
impl !RefUnwindSafe for P2p
impl Send for P2p
impl Sync for P2p
impl Unpin for P2p
impl !UnwindSafe for P2p
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more