pub struct NodeClient { /* private fields */ }Expand description
NodeClient is responsible for steering NodeWorker by sending it commands and receiving
responses over the provided port.
Implementations§
Source§impl NodeClient
impl NodeClient
Sourcepub async fn new(port: JsValue) -> Result<NodeClient>
pub async fn new(port: JsValue) -> Result<NodeClient>
Create a new connection to a Lumina node running in [NodeWorker]. Provided port is
expected to have MessagePort-like interface for sending and receiving messages.
Sourcepub async fn add_connection_to_worker(&self, port: JsValue) -> Result<()>
pub async fn add_connection_to_worker(&self, port: JsValue) -> Result<()>
Establish a new connection to the existing worker over provided port
Sourcepub async fn is_running(&self) -> Result<bool>
pub async fn is_running(&self) -> Result<bool>
Check whether Lumina is currently running
Sourcepub async fn start(&self, config: &WasmNodeConfig) -> Result<()>
pub async fn start(&self, config: &WasmNodeConfig) -> Result<()>
Start the node with the provided config, if it’s not running
Sourcepub async fn local_peer_id(&self) -> Result<String>
pub async fn local_peer_id(&self) -> Result<String>
Get node’s local peer ID.
Sourcepub async fn peer_tracker_info(&self) -> Result<PeerTrackerInfoSnapshot>
pub async fn peer_tracker_info(&self) -> Result<PeerTrackerInfoSnapshot>
Get current [PeerTracker] info.
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<NetworkInfoSnapshot>
pub async fn network_info(&self) -> Result<NetworkInfoSnapshot>
Get current network info.
Sourcepub async fn listeners(&self) -> Result<Array>
pub async fn listeners(&self) -> Result<Array>
Get all the multiaddresses on which the node listens.
Sourcepub async fn connected_peers(&self) -> Result<Array>
pub async fn connected_peers(&self) -> Result<Array>
Get all the peers that node is connected to.
Sourcepub async fn set_peer_trust(
&self,
peer_id: &str,
is_trusted: bool,
) -> Result<()>
pub async fn set_peer_trust( &self, peer_id: &str, 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: &str) -> Result<ExtendedHeader>
pub async fn request_header_by_hash(&self, hash: &str) -> Result<ExtendedHeader>
Request a header for the block with a given hash from the network.
Sourcepub async fn request_header_by_height(
&self,
height: u64,
) -> Result<ExtendedHeader>
pub async fn request_header_by_height( &self, height: 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_all_blobs(
&self,
namespace: &Namespace,
block_height: u64,
timeout_secs: Option<f64>,
) -> Result<Vec<Blob>>
pub async fn request_all_blobs( &self, namespace: &Namespace, block_height: u64, timeout_secs: Option<f64>, ) -> 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<SyncingInfoSnapshot>
pub async fn syncer_info(&self) -> Result<SyncingInfoSnapshot>
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: &str) -> Result<ExtendedHeader>
pub async fn get_header_by_hash(&self, hash: &str) -> 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(
&self,
start_height: Option<u64>,
end_height: Option<u64>,
) -> Result<Vec<ExtendedHeader>>
pub async fn get_headers( &self, start_height: Option<u64>, end_height: Option<u64>, ) -> Result<Vec<ExtendedHeader>>
Get synced headers from the given heights range.
If start of the range is undefined (None), the first returned header will be of height 1. If end of the range is undefined (None), 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.
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.
Sourcepub async fn events_channel(&self) -> Result<BroadcastChannel>
pub async fn events_channel(&self) -> Result<BroadcastChannel>
Returns a BroadcastChannel for events generated by [Node].
Trait Implementations§
Source§impl From<NodeClient> for JsValue
impl From<NodeClient> for JsValue
Source§fn from(value: NodeClient) -> Self
fn from(value: NodeClient) -> Self
Source§impl FromWasmAbi for NodeClient
impl FromWasmAbi for NodeClient
Source§impl IntoWasmAbi for NodeClient
impl IntoWasmAbi for NodeClient
Source§impl LongRefFromWasmAbi for NodeClient
impl LongRefFromWasmAbi for NodeClient
Source§impl OptionFromWasmAbi for NodeClient
impl OptionFromWasmAbi for NodeClient
Source§impl OptionIntoWasmAbi for NodeClient
impl OptionIntoWasmAbi for NodeClient
Source§impl RefFromWasmAbi for NodeClient
impl RefFromWasmAbi for NodeClient
Source§type Anchor = RcRef<NodeClient>
type Anchor = RcRef<NodeClient>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for NodeClient
impl RefMutFromWasmAbi for NodeClient
Source§impl TryFromJsValue for NodeClient
impl TryFromJsValue for NodeClient
Source§impl VectorFromWasmAbi for NodeClient
impl VectorFromWasmAbi for NodeClient
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[NodeClient]>
Source§impl VectorIntoWasmAbi for NodeClient
impl VectorIntoWasmAbi for NodeClient
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[NodeClient]>) -> Self::Abi
Source§impl WasmDescribeVector for NodeClient
impl WasmDescribeVector for NodeClient
impl SupportsConstructor for NodeClient
impl SupportsInstanceProperty for NodeClient
impl SupportsStaticProperty for NodeClient
Auto Trait Implementations§
impl Freeze for NodeClient
impl RefUnwindSafe for NodeClient
impl !Send for NodeClient
impl !Sync for NodeClient
impl Unpin for NodeClient
impl UnwindSafe for NodeClient
Blanket Implementations§
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§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> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.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.