NodeRpcClient

Trait NodeRpcClient 

Source
pub trait NodeRpcClient: Send + Sync {
Show 16 methods // Required methods fn set_genesis_commitment<'life0, 'async_trait>( &'life0 self, commitment: Word, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn submit_proven_transaction<'life0, 'async_trait>( &'life0 self, proven_transaction: ProvenTransaction, ) -> Pin<Box<dyn Future<Output = Result<BlockNumber, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_block_header_by_number<'life0, 'async_trait>( &'life0 self, block_num: Option<BlockNumber>, include_mmr_proof: bool, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, Option<MmrProof>), RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_block_by_number<'life0, 'async_trait>( &'life0 self, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<ProvenBlock, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_notes_by_id<'life0, 'life1, 'async_trait>( &'life0 self, note_ids: &'life1 [NoteId], ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedNote>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn sync_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, block_num: BlockNumber, account_ids: &'life1 [AccountId], note_tags: &'life2 BTreeSet<NoteTag>, ) -> Pin<Box<dyn Future<Output = Result<StateSyncInfo, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn get_account_details<'life0, 'async_trait>( &'life0 self, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<FetchedAccount, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sync_notes<'life0, 'life1, 'async_trait>( &'life0 self, block_num: BlockNumber, note_tags: &'life1 BTreeSet<NoteTag>, ) -> Pin<Box<dyn Future<Output = Result<NoteSyncInfo, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn check_nullifiers_by_prefix<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 [u16], block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<Vec<NullifierUpdate>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn check_nullifiers<'life0, 'life1, 'async_trait>( &'life0 self, nullifiers: &'life1 [Nullifier], ) -> Pin<Box<dyn Future<Output = Result<Vec<SmtProof>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_account_proofs<'life0, 'life1, 'async_trait>( &'life0 self, account_storage_requests: &'life1 BTreeSet<ForeignAccount>, known_account_codes: Vec<AccountCode>, ) -> Pin<Box<dyn Future<Output = Result<AccountProofs, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn get_nullifier_commit_height<'life0, 'life1, 'async_trait>( &'life0 self, nullifier: &'life1 Nullifier, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_public_note_records<'life0, 'life1, 'async_trait>( &'life0 self, note_ids: &'life1 [NoteId], current_timestamp: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Vec<InputNoteRecord>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_updated_public_accounts<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, local_accounts: &'life1 [&'life2 AccountHeader], ) -> Pin<Box<dyn Future<Output = Result<Vec<Account>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn get_block_header_with_proof<'life0, 'async_trait>( &'life0 self, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, MmrProof), RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_note_by_id<'life0, 'async_trait>( &'life0 self, note_id: NoteId, ) -> Pin<Box<dyn Future<Output = Result<FetchedNote, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

Defines the interface for communicating with the Miden node.

The implementers are responsible for connecting to the Miden node, handling endpoint requests/responses, and translating responses into domain objects relevant for each of the endpoints.

Required Methods§

Source

fn set_genesis_commitment<'life0, 'async_trait>( &'life0 self, commitment: Word, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the genesis commitment for the client and reconnects to the node providing the genesis commitment in the request headers. If the genesis commitment is already set, this method does nothing.

Source

fn submit_proven_transaction<'life0, 'async_trait>( &'life0 self, proven_transaction: ProvenTransaction, ) -> Pin<Box<dyn Future<Output = Result<BlockNumber, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Given a Proven Transaction, send it to the node for it to be included in a future block using the /SubmitProvenTransaction RPC endpoint.

Source

fn get_block_header_by_number<'life0, 'async_trait>( &'life0 self, block_num: Option<BlockNumber>, include_mmr_proof: bool, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, Option<MmrProof>), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Given a block number, fetches the block header corresponding to that height from the node using the /GetBlockHeaderByNumber endpoint. If include_mmr_proof is set to true and the function returns an Ok, the second value of the return tuple should always be Some(MmrProof).

When None is provided, returns info regarding the latest block.

Source

fn get_block_by_number<'life0, 'async_trait>( &'life0 self, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<ProvenBlock, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Given a block number, fetches the block corresponding to that height from the node using the /GetBlockByNumber RPC endpoint.

Source

fn get_notes_by_id<'life0, 'life1, 'async_trait>( &'life0 self, note_ids: &'life1 [NoteId], ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedNote>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches note-related data for a list of NoteId using the /GetNotesById rpc endpoint.

For any miden_objects::note::NoteType::Private note, the return data is only the miden_objects::note::NoteMetadata, whereas for miden_objects::note::NoteType::Public notes, the return data includes all details.

Source

fn sync_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, block_num: BlockNumber, account_ids: &'life1 [AccountId], note_tags: &'life2 BTreeSet<NoteTag>, ) -> Pin<Box<dyn Future<Output = Result<StateSyncInfo, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetches info from the node necessary to perform a state sync using the /SyncState RPC endpoint.

  • block_num is the last block number known by the client. The returned StateSyncInfo should contain data starting from the next block, until the first block which contains a note of matching the requested tag, or the chain tip if there are no notes.
  • account_ids is a list of account IDs and determines the accounts the client is interested in and should receive account updates of.
  • note_tags is a list of tags used to filter the notes the client is interested in, which serves as a “note group” filter. Notice that you can’t filter by a specific note ID.
  • nullifiers_tags similar to note_tags, is a list of tags used to filter the nullifiers corresponding to some notes the client is interested in.
Source

fn get_account_details<'life0, 'async_trait>( &'life0 self, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<FetchedAccount, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches the current state of an account from the node using the /GetAccountDetails RPC endpoint.

  • account_id is the ID of the wanted account.
Source

fn sync_notes<'life0, 'life1, 'async_trait>( &'life0 self, block_num: BlockNumber, note_tags: &'life1 BTreeSet<NoteTag>, ) -> Pin<Box<dyn Future<Output = Result<NoteSyncInfo, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches the notes related to the specified tags using the /SyncNotes RPC endpoint.

  • block_num is the last block number known by the client.
  • note_tags is a list of tags used to filter the notes the client is interested in.
Source

fn check_nullifiers_by_prefix<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 [u16], block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<Vec<NullifierUpdate>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches the nullifiers corresponding to a list of prefixes using the /CheckNullifiersByPrefix RPC endpoint.

  • prefix is a list of nullifiers prefixes to search for.
  • block_num is the block number to start the search from. Nullifiers created in this block or the following blocks will be included.
Source

fn check_nullifiers<'life0, 'life1, 'async_trait>( &'life0 self, nullifiers: &'life1 [Nullifier], ) -> Pin<Box<dyn Future<Output = Result<Vec<SmtProof>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches the nullifier proofs corresponding to a list of nullifiers using the /CheckNullifiers RPC endpoint.

Source

fn get_account_proofs<'life0, 'life1, 'async_trait>( &'life0 self, account_storage_requests: &'life1 BTreeSet<ForeignAccount>, known_account_codes: Vec<AccountCode>, ) -> Pin<Box<dyn Future<Output = Result<AccountProofs, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches the account data needed to perform a Foreign Procedure Invocation (FPI) on the specified foreign accounts, using the GetAccountProofs endpoint.

The code_commitments parameter is a list of known code commitments to prevent unnecessary data fetching. Returns the block number and the FPI account data. If one of the tracked accounts is not found in the node, the method will return an error.

Provided Methods§

Source

fn get_nullifier_commit_height<'life0, 'life1, 'async_trait>( &'life0 self, nullifier: &'life1 Nullifier, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches the commit height where the nullifier was consumed. If the nullifier isn’t found, then None is returned. The block_num parameter is the block number to start the search from.

The default implementation of this method uses NodeRpcClient::check_nullifiers_by_prefix.

Source

fn get_public_note_records<'life0, 'life1, 'async_trait>( &'life0 self, note_ids: &'life1 [NoteId], current_timestamp: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Vec<InputNoteRecord>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches public note-related data for a list of NoteId and builds InputNoteRecords with it. If a note is not found or it’s private, it is ignored and will not be included in the returned list.

The default implementation of this method uses NodeRpcClient::get_notes_by_id.

Source

fn get_updated_public_accounts<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, local_accounts: &'life1 [&'life2 AccountHeader], ) -> Pin<Box<dyn Future<Output = Result<Vec<Account>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetches the public accounts that have been updated since the last known state of the accounts.

The local_accounts parameter is a list of account headers that the client has stored locally and that it wants to check for updates. If an account is private or didn’t change, it is ignored and will not be included in the returned list. The default implementation of this method uses NodeRpcClient::get_account_details.

Source

fn get_block_header_with_proof<'life0, 'async_trait>( &'life0 self, block_num: BlockNumber, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, MmrProof), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Given a block number, fetches the block header corresponding to that height from the node along with the MMR proof.

The default implementation of this method uses NodeRpcClient::get_block_header_by_number.

Source

fn get_note_by_id<'life0, 'async_trait>( &'life0 self, note_id: NoteId, ) -> Pin<Box<dyn Future<Output = Result<FetchedNote, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches the note with the specified ID.

The default implementation of this method uses NodeRpcClient::get_notes_by_id.

Errors:

Implementors§