pub struct Node<B, S>where
B: Blockstore + 'static,
S: Store + 'static,{ /* private fields */ }
Expand description
Celestia node.
Implementations§
Source§impl Node<InMemoryBlockstore, InMemoryStore>
impl Node<InMemoryBlockstore, InMemoryStore>
Sourcepub fn builder() -> NodeBuilder<InMemoryBlockstore, InMemoryStore>
pub fn builder() -> NodeBuilder<InMemoryBlockstore, InMemoryStore>
Creates a new NodeBuilder
that is using in-memory stores.
After the creation you can use NodeBuilder::blockstore
and NodeBuilder::store
to set other stores.
§Example
let node = Node::builder()
.network(Network::Mainnet)
.start()
.await
.unwrap();
Source§impl<B, S> Node<B, S>where
B: Blockstore,
S: Store,
impl<B, S> Node<B, S>where
B: Blockstore,
S: Store,
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_row(
&self,
row_index: u16,
block_height: u64,
timeout: Option<Duration>,
) -> Result<Row>
pub async fn request_row( &self, row_index: u16, block_height: u64, timeout: Option<Duration>, ) -> Result<Row>
Sourcepub async fn request_sample(
&self,
row_index: u16,
column_index: u16,
block_height: u64,
timeout: Option<Duration>,
) -> Result<Sample>
pub async fn request_sample( &self, row_index: u16, column_index: u16, block_height: u64, timeout: Option<Duration>, ) -> Result<Sample>
Sourcepub async fn request_row_namespace_data(
&self,
namespace: Namespace,
row_index: u16,
block_height: u64,
timeout: Option<Duration>,
) -> Result<RowNamespaceData>
pub async fn request_row_namespace_data( &self, namespace: Namespace, row_index: u16, block_height: u64, timeout: Option<Duration>, ) -> 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 request_all_blobs(
&self,
namespace: Namespace,
block_height: u64,
timeout: Option<Duration>,
) -> Result<Vec<Blob>>
pub async fn request_all_blobs( &self, namespace: Namespace, block_height: u64, timeout: Option<Duration>, ) -> Result<Vec<Blob>>
Request all blobs with provided namespace in the block corresponding to this header using bitswap protocol.
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.