pub struct PolkadotNodeClient { /* private fields */ }Expand description
subxt-backed Midnight node client.
Construct with PolkadotNodeClient::connect (async — fetches runtime
metadata). Each call to PolkadotNodeClient::send_midnight_transaction
reuses the held OnlineClient — subxt keeps the WebSocket open across
submissions.
Implementations§
Source§impl PolkadotNodeClient
impl PolkadotNodeClient
Sourcepub async fn connect(config: Config) -> Result<Self, NodeClientError>
pub async fn connect(config: Config) -> Result<Self, NodeClientError>
Connect to the node and fetch runtime metadata.
Fails with NodeClientError::Connection if the node is unreachable
or the metadata download fails.
Sourcepub fn api(&self) -> &OnlineClient<SubstrateConfig>
pub fn api(&self) -> &OnlineClient<SubstrateConfig>
Access the wrapped subxt client — escape hatch for advanced callers who need to issue custom queries against the same connection.
Trait Implementations§
Source§impl NodeClient for PolkadotNodeClient
impl NodeClient for PolkadotNodeClient
Source§fn genesis_hash_hex(&self) -> Option<String>
fn genesis_hash_hex(&self) -> Option<String>
The chain’s genesis block hash,
0x-prefixed hex. Identifies
the chain instance: two runs of a local-dev chain have
different genesis hashes even though both call themselves
localdev. Snapshot stores use this to refuse resuming state
captured against a chain that no longer exists. None when
the client can’t know it (offline test doubles).Source§fn send_midnight_transaction<'life0, 'async_trait>(
&'life0 self,
tx: SerializedTransaction,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<SubmissionEvent, NodeClientError>>, NodeClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_midnight_transaction<'life0, 'async_trait>(
&'life0 self,
tx: SerializedTransaction,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<SubmissionEvent, NodeClientError>>, NodeClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Submit a Midnight transaction and stream every subsequent status
event until the stream terminates with
SubmissionEvent::Finalized,
a terminal error, or the caller drops the stream. Read moreSource§fn get_genesis<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Genesis, NodeClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_genesis<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Genesis, NodeClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fetch the genesis block and extract its embedded Midnight transactions. Read more
Source§fn send_and_wait_for<'life0, 'async_trait>(
&'life0 self,
tx: SerializedTransaction,
stage: SubmissionStage,
) -> Pin<Box<dyn Future<Output = Result<SubmissionEvent, NodeClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_and_wait_for<'life0, 'async_trait>(
&'life0 self,
tx: SerializedTransaction,
stage: SubmissionStage,
) -> Pin<Box<dyn Future<Output = Result<SubmissionEvent, NodeClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Submit a transaction and return the first event matching
stage, or
propagate the first error the stream reports. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for PolkadotNodeClient
impl !UnwindSafe for PolkadotNodeClient
impl Forget for PolkadotNodeClient
impl Freeze for PolkadotNodeClientwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<OnlineClientInner<SubstrateConfig>> is !null: Freeze,
PhantomData<ArcInner<OnlineClientInner<SubstrateConfig>>>: Freeze,
impl Move for PolkadotNodeClient
impl Send for PolkadotNodeClient
impl Sync for PolkadotNodeClient
impl Unpin for PolkadotNodeClient
impl UnsafeUnpin for PolkadotNodeClientwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<OnlineClientInner<SubstrateConfig>> is !null: UnsafeUnpin,
PhantomData<ArcInner<OnlineClientInner<SubstrateConfig>>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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