DataStore

Trait DataStore 

Source
pub trait DataStore: MastForestStore {
    // Required methods
    fn get_transaction_inputs(
        &self,
        account_id: AccountId,
        ref_blocks: BTreeSet<BlockNumber>,
    ) -> impl FutureMaybeSend<Result<(PartialAccount, BlockHeader, PartialBlockchain), DataStoreError>>;
    fn get_foreign_account_inputs(
        &self,
        foreign_account_id: AccountId,
        ref_block: BlockNumber,
    ) -> impl FutureMaybeSend<Result<AccountInputs, DataStoreError>>;
    fn get_vault_asset_witness(
        &self,
        account_id: AccountId,
        vault_root: Word,
        vault_key: AssetVaultKey,
    ) -> impl FutureMaybeSend<Result<AssetWitness, DataStoreError>>;
    fn get_storage_map_witness(
        &self,
        account_id: AccountId,
        map_root: Word,
        map_key: Word,
    ) -> impl FutureMaybeSend<Result<StorageMapWitness, DataStoreError>>;
    fn get_note_script(
        &self,
        script_root: Word,
    ) -> impl FutureMaybeSend<Result<NoteScript, DataStoreError>>;
}
Expand description

The DataStore trait defines the interface that transaction objects use to fetch data required for transaction execution.

Required Methods§

Source

fn get_transaction_inputs( &self, account_id: AccountId, ref_blocks: BTreeSet<BlockNumber>, ) -> impl FutureMaybeSend<Result<(PartialAccount, BlockHeader, PartialBlockchain), DataStoreError>>

Returns all the data required to execute a transaction against the account with the specified ID and consuming input notes created in blocks in the input ref_blocks set.

The highest block number in ref_blocks will be the transaction reference block. In general, it is recommended that the reference corresponds to the latest block available in the data store.

§Errors

Returns an error if:

  • The account with the specified ID could not be found in the data store.
  • The block with the specified number could not be found in the data store.
  • The combination of specified inputs resulted in a transaction input error.
  • The data store encountered some internal error
Source

fn get_foreign_account_inputs( &self, foreign_account_id: AccountId, ref_block: BlockNumber, ) -> impl FutureMaybeSend<Result<AccountInputs, DataStoreError>>

Returns a partial foreign account state together with a witness, proving its validity in the specified transaction reference block.

Source

fn get_vault_asset_witness( &self, account_id: AccountId, vault_root: Word, vault_key: AssetVaultKey, ) -> impl FutureMaybeSend<Result<AssetWitness, DataStoreError>>

Returns a witness for an asset in the requested account’s vault with the requested vault root.

This is the witness that needs to be added to the advice provider’s merkle store and advice map to make access to the specified asset possible.

Source

fn get_storage_map_witness( &self, account_id: AccountId, map_root: Word, map_key: Word, ) -> impl FutureMaybeSend<Result<StorageMapWitness, DataStoreError>>

Returns a witness for a storage map item identified by map_key in the requested account’s storage with the requested storage map_root.

Note that the map_key needs to be hashed in order to get the actual key into the storage map.

This is the witness that needs to be added to the advice provider’s merkle store and advice map to make access to the specified storage map item possible.

Source

fn get_note_script( &self, script_root: Word, ) -> impl FutureMaybeSend<Result<NoteScript, DataStoreError>>

Returns a note script with the specified root.

This method will try to find a note script with the specified root in the data store, and if not found, return an error.

§Errors

Returns an error if:

  • The note script with the specified root could not be found in the data store.
  • The data store encountered some internal error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§