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_witnesses(
&self,
account_id: AccountId,
vault_root: Word,
asset_ids: BTreeSet<AssetId>,
) -> impl FutureMaybeSend<Result<Vec<AssetWitness>, DataStoreError>>;
fn get_storage_map_witness(
&self,
account_id: AccountId,
map_root: Word,
map_key: StorageMapKey,
) -> impl FutureMaybeSend<Result<StorageMapWitness, DataStoreError>>;
fn get_note_script(
&self,
script_root: NoteScriptRoot,
) -> impl FutureMaybeSend<Result<Option<NoteScript>, DataStoreError>>;
}testing only.Expand description
The data store the executor reads from, along with the trait whose methods it serves. Exposed here so that tests can exercise it on its own, without going through a transaction or a note screening pass. The DataStore trait defines the interface that transaction objects use to fetch data required for transaction execution.
Required Methods§
Sourcefn get_transaction_inputs(
&self,
account_id: AccountId,
ref_blocks: BTreeSet<BlockNumber>,
) -> impl FutureMaybeSend<Result<(PartialAccount, BlockHeader, PartialBlockchain), DataStoreError>>
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
Sourcefn get_foreign_account_inputs(
&self,
foreign_account_id: AccountId,
ref_block: BlockNumber,
) -> impl FutureMaybeSend<Result<AccountInputs, DataStoreError>>
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.
Sourcefn get_vault_asset_witnesses(
&self,
account_id: AccountId,
vault_root: Word,
asset_ids: BTreeSet<AssetId>,
) -> impl FutureMaybeSend<Result<Vec<AssetWitness>, DataStoreError>>
fn get_vault_asset_witnesses( &self, account_id: AccountId, vault_root: Word, asset_ids: BTreeSet<AssetId>, ) -> impl FutureMaybeSend<Result<Vec<AssetWitness>, DataStoreError>>
Returns witnesses for the asset IDs in the requested account’s vault with the requested vault root.
These are the witnesses that need to be added to the advice provider’s merkle store and advice map to make access to the corresponding assets possible.
Sourcefn get_storage_map_witness(
&self,
account_id: AccountId,
map_root: Word,
map_key: StorageMapKey,
) -> impl FutureMaybeSend<Result<StorageMapWitness, DataStoreError>>
fn get_storage_map_witness( &self, account_id: AccountId, map_root: Word, map_key: StorageMapKey, ) -> 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.
Sourcefn get_note_script(
&self,
script_root: NoteScriptRoot,
) -> impl FutureMaybeSend<Result<Option<NoteScript>, DataStoreError>>
fn get_note_script( &self, script_root: NoteScriptRoot, ) -> impl FutureMaybeSend<Result<Option<NoteScript>, DataStoreError>>
Returns a note script with the specified root, or None if not found.
This method will try to find a note script with the specified root in the data store.
If the script is not found, it returns Ok(None) rather than an error, as “not found”
is a valid, expected outcome.
Note: Data store implementers do not need to handle standard note scripts (e.g. P2ID). These are resolved directly by the transaction executor and will not trigger this method.
§Errors
Returns an error if the data store encountered an internal error while attempting to retrieve the script.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".