Struct lumina_node::node::Node
source · pub struct Node<S>where
S: Store + 'static,{ /* private fields */ }Expand description
Celestia node.
Implementations§
source§impl<S> Node<S>where
S: Store,
impl<S> Node<S>where
S: Store,
sourcepub async fn new(config: NodeConfig<S>) -> Result<Self, NodeError>
pub async fn new(config: NodeConfig<S>) -> Result<Self, NodeError>
Creates and starts a new celestia node with a given config.
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 PeerTracker info.
sourcepub async fn wait_connected(&self) -> Result<(), NodeError>
pub async fn wait_connected(&self) -> Result<(), NodeError>
Wait until the node is connected to at least 1 peer.
sourcepub async fn wait_connected_trusted(&self) -> Result<(), NodeError>
pub async fn wait_connected_trusted(&self) -> Result<(), NodeError>
Wait until the node is connected to at least 1 trusted peer.
sourcepub async fn network_info(&self) -> Result<NetworkInfo, NodeError>
pub async fn network_info(&self) -> Result<NetworkInfo, NodeError>
Get current network info.
sourcepub async fn listeners(&self) -> Result<Vec<Multiaddr>, NodeError>
pub async fn listeners(&self) -> Result<Vec<Multiaddr>, NodeError>
Get all the multiaddresses on which the node listens.
sourcepub async fn connected_peers(&self) -> Result<Vec<PeerId>, NodeError>
pub async fn connected_peers(&self) -> Result<Vec<PeerId>, NodeError>
Get all the peers that node is connected to.
sourcepub async fn set_peer_trust(
&self,
peer_id: PeerId,
is_trusted: bool
) -> Result<(), NodeError>
pub async fn set_peer_trust( &self, peer_id: PeerId, is_trusted: bool ) -> Result<(), NodeError>
Trust or untrust the peer with a given ID.
sourcepub async fn request_head_header(&self) -> Result<ExtendedHeader, NodeError>
pub async fn request_head_header(&self) -> Result<ExtendedHeader, NodeError>
Request the head header from the network.
sourcepub async fn request_header_by_hash(
&self,
hash: &Hash
) -> Result<ExtendedHeader, NodeError>
pub async fn request_header_by_hash( &self, hash: &Hash ) -> Result<ExtendedHeader, NodeError>
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, NodeError>
pub async fn request_header_by_height( &self, hash: u64 ) -> Result<ExtendedHeader, NodeError>
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>, NodeError>
pub async fn request_verified_headers( &self, from: &ExtendedHeader, amount: u64 ) -> Result<Vec<ExtendedHeader>, NodeError>
Request headers in range (from, from + amount] from the network.
The headers will be verified with the from header.
sourcepub async fn syncer_info(&self) -> Result<SyncingInfo, NodeError>
pub async fn syncer_info(&self) -> Result<SyncingInfo, NodeError>
Get current header syncing info.
sourcepub fn get_network_head_header(&self) -> Option<ExtendedHeader>
pub fn get_network_head_header(&self) -> Option<ExtendedHeader>
Get the latest header announced in the network.
sourcepub async fn get_local_head_header(&self) -> Result<ExtendedHeader, NodeError>
pub async fn get_local_head_header(&self) -> Result<ExtendedHeader, NodeError>
Get the latest locally synced header.
sourcepub async fn get_header_by_hash(
&self,
hash: &Hash
) -> Result<ExtendedHeader, NodeError>
pub async fn get_header_by_hash( &self, hash: &Hash ) -> Result<ExtendedHeader, NodeError>
Get a synced header for the block with a given hash.
sourcepub async fn get_header_by_height(
&self,
height: u64
) -> Result<ExtendedHeader, NodeError>
pub async fn get_header_by_height( &self, height: u64 ) -> Result<ExtendedHeader, NodeError>
Get a synced header for the block with a given height.
sourcepub async fn get_headers<R>(
&self,
range: R
) -> Result<Vec<ExtendedHeader>, NodeError>
pub async fn get_headers<R>( &self, range: R ) -> Result<Vec<ExtendedHeader>, NodeError>
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.