Skip to main content

NodeClient

Trait NodeClient 

Source
pub trait NodeClient: Send + Sync {
    // Required methods
    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 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;

    // Provided methods
    fn genesis_hash_hex(&self) -> Option<String> { ... }
    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 { ... }
}
Expand description

Client for the Midnight node’s submission RPC.

Concrete impls live alongside this trait. The default is the subxt-backed PolkadotNodeClient (added behind a feature flag so the pure-logic layer remains Substrate-free and testable without a full toolchain).

Required Methods§

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,

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.

The implementation is responsible for:

Source

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.

Corresponds to TS getGenesis() — used for initial-state bootstrap.

Provided Methods§

Source

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_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.

Default impl drives the stream; concrete clients rarely need to override. Mirrors TS sendMidnightTransactionAndWait.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§