pub struct Node<B, S>where
B: Blockstore + 'static,
S: Store + 'static,{ /* private fields */ }
Expand description
Celestia node.
Implementations§
source§impl<B, S> Node<B, S>where
B: Blockstore,
S: Store,
impl<B, S> Node<B, S>where
B: Blockstore,
S: Store,
sourcepub async fn new(config: NodeConfig<B, S>) -> Result<Self>
pub async fn new(config: NodeConfig<B, S>) -> Result<Self>
Creates and starts a new celestia node with a given config.
sourcepub async fn new_subscribed(
config: NodeConfig<B, S>,
) -> Result<(Self, EventSubscriber)>
pub async fn new_subscribed( config: NodeConfig<B, S>, ) -> Result<(Self, EventSubscriber)>
Creates and starts a new celestia node with a given config.
Returns Node
alogn with EventSubscriber
. Use this to avoid missing any
events that will be generated on the construction of the node.
sourcepub fn event_subscriber(&self) -> EventSubscriber
pub fn event_subscriber(&self) -> EventSubscriber
Returns a new EventSubscriber
.
sourcepub fn local_peer_id(&self) -> &PeerId
pub fn local_peer_id(&self) -> &PeerId
Get node’s local peer ID.
sourcepub fn peer_tracker_info(&self) -> PeerTrackerInfo
pub fn peer_tracker_info(&self) -> PeerTrackerInfo
Get current PeerTrackerInfo
.
sourcepub fn peer_tracker_info_watcher(&self) -> Receiver<PeerTrackerInfo>
pub fn peer_tracker_info_watcher(&self) -> Receiver<PeerTrackerInfo>
Get PeerTrackerInfo
watcher.
sourcepub async fn wait_connected(&self) -> Result<()>
pub async fn wait_connected(&self) -> Result<()>
Wait until the node is connected to at least 1 peer.
sourcepub async fn wait_connected_trusted(&self) -> Result<()>
pub async fn wait_connected_trusted(&self) -> Result<()>
Wait until the node is connected to at least 1 trusted peer.
sourcepub async fn network_info(&self) -> Result<NetworkInfo>
pub async fn network_info(&self) -> Result<NetworkInfo>
Get current network info.
sourcepub async fn listeners(&self) -> Result<Vec<Multiaddr>>
pub async fn listeners(&self) -> Result<Vec<Multiaddr>>
Get all the multiaddresses on which the node listens.
sourcepub async fn connected_peers(&self) -> Result<Vec<PeerId>>
pub async fn connected_peers(&self) -> Result<Vec<PeerId>>
Get all the peers that node is connected to.
sourcepub async fn set_peer_trust(
&self,
peer_id: PeerId,
is_trusted: bool,
) -> Result<()>
pub async fn set_peer_trust( &self, peer_id: PeerId, is_trusted: bool, ) -> Result<()>
Trust or untrust the peer with a given ID.
sourcepub async fn request_head_header(&self) -> Result<ExtendedHeader>
pub async fn request_head_header(&self) -> Result<ExtendedHeader>
Request the head header from the network.
sourcepub async fn request_header_by_hash(
&self,
hash: &Hash,
) -> Result<ExtendedHeader>
pub async fn request_header_by_hash( &self, hash: &Hash, ) -> Result<ExtendedHeader>
Request a header for the block with a given hash from the network.
sourcepub async fn request_header_by_height(
&self,
hash: u64,
) -> Result<ExtendedHeader>
pub async fn request_header_by_height( &self, hash: u64, ) -> Result<ExtendedHeader>
Request a header for the block with a given height from the network.
sourcepub async fn request_verified_headers(
&self,
from: &ExtendedHeader,
amount: u64,
) -> Result<Vec<ExtendedHeader>>
pub async fn request_verified_headers( &self, from: &ExtendedHeader, amount: u64, ) -> Result<Vec<ExtendedHeader>>
Request headers in range (from, from + amount] from the network.
The headers will be verified with the from
header.
sourcepub async fn request_sample(
&self,
row_index: u16,
column_index: u16,
block_height: u64,
) -> Result<Sample>
pub async fn request_sample( &self, row_index: u16, column_index: u16, block_height: u64, ) -> Result<Sample>
sourcepub async fn request_row_namespace_data(
&self,
namespace: Namespace,
row_index: u16,
block_height: u64,
) -> Result<RowNamespaceData>
pub async fn request_row_namespace_data( &self, namespace: Namespace, row_index: u16, block_height: u64, ) -> Result<RowNamespaceData>
Request a verified RowNamespaceData
from the network.
§Errors
On failure to receive a verified RowNamespaceData
within a certain time, the
NodeError::P2p(P2pError::BitswapQueryTimeout)
error will be returned.
sourcepub async fn syncer_info(&self) -> Result<SyncingInfo>
pub async fn syncer_info(&self) -> Result<SyncingInfo>
Get current header syncing info.
sourcepub async fn get_network_head_header(&self) -> Result<Option<ExtendedHeader>>
pub async fn get_network_head_header(&self) -> Result<Option<ExtendedHeader>>
Get the latest header announced in the network.
sourcepub async fn get_local_head_header(&self) -> Result<ExtendedHeader>
pub async fn get_local_head_header(&self) -> Result<ExtendedHeader>
Get the latest locally synced header.
sourcepub async fn get_header_by_hash(&self, hash: &Hash) -> Result<ExtendedHeader>
pub async fn get_header_by_hash(&self, hash: &Hash) -> Result<ExtendedHeader>
Get a synced header for the block with a given hash.
sourcepub async fn get_header_by_height(&self, height: u64) -> Result<ExtendedHeader>
pub async fn get_header_by_height(&self, height: u64) -> Result<ExtendedHeader>
Get a synced header for the block with a given height.
sourcepub async fn get_headers<R>(&self, range: R) -> Result<Vec<ExtendedHeader>>
pub async fn get_headers<R>(&self, range: R) -> Result<Vec<ExtendedHeader>>
Get synced headers from the given heights range.
If start of the range is unbounded, the first returned header will be of height 1. If end of the range is unbounded, the last returned header will be the last header in the store.
§Errors
If range contains a height of a header that is not found in the store or RangeBounds
cannot be converted to a valid range.
sourcepub async fn get_sampling_metadata(
&self,
height: u64,
) -> Result<Option<SamplingMetadata>>
pub async fn get_sampling_metadata( &self, height: u64, ) -> Result<Option<SamplingMetadata>>
Get data sampling metadata of an already sampled height.
Returns Ok(None)
if metadata for the given height does not exists.
Trait Implementations§
Auto Trait Implementations§
impl<B, S> Freeze for Node<B, S>
impl<B, S> RefUnwindSafe for Node<B, S>where
B: RefUnwindSafe,
S: RefUnwindSafe,
impl<B, S> Send for Node<B, S>
impl<B, S> Sync for Node<B, S>
impl<B, S> Unpin for Node<B, S>
impl<B, S> UnwindSafe for Node<B, S>where
B: RefUnwindSafe,
S: RefUnwindSafe,
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