pub struct Database { /* private fields */ }Implementations
sourceimpl Database
impl Database
pub fn get_block_height(&self) -> Result<Option<BlockHeight>, Error>
pub fn get_block_id(
&self,
height: BlockHeight
) -> Result<Option<Bytes32>, Error>
pub fn all_block_ids(
&self,
start: Option<BlockHeight>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<(BlockHeight, Bytes32), Error>> + '_
sourceimpl Database
impl Database
pub fn owned_coins(
&self,
owner: Address,
start_coin: Option<UtxoId>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<UtxoId, Error>> + '_
pub fn owned_coins_by_asset_id(
&self,
owner: Address,
asset_id: AssetId,
start_coin: Option<UtxoId>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<UtxoId, Error>> + '_
sourceimpl Database
impl Database
pub fn init_chain_name(&self, name: String) -> Result<(), Error>
pub fn get_chain_name(&self) -> Result<Option<String>, Error>
pub fn init_chain_height(&self, height: BlockHeight) -> Result<(), Error>
pub fn get_starting_chain_height(&self) -> Result<Option<BlockHeight>, Error>
sourceimpl Database
impl Database
pub fn all_transactions(
&self,
start: Option<&Bytes32>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<Transaction, Error>> + '_
sourcepub fn owned_transactions(
&self,
owner: &Address,
start: Option<&OwnedTransactionIndexCursor>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<(OwnedTransactionIndexCursor, Bytes32), Error>> + '_
pub fn owned_transactions(
&self,
owner: &Address,
start: Option<&OwnedTransactionIndexCursor>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<(OwnedTransactionIndexCursor, Bytes32), Error>> + '_
Iterates over a KV mapping of [address + block height + tx idx] => transaction id. This
allows for efficient lookup of transaction ids associated with an address, sorted by
block age and ordering within a block. The cursor tracks the [block height + tx idx] for
pagination purposes.
pub fn record_tx_id_owner(
&self,
owner: &Address,
block_height: BlockHeight,
tx_idx: TransactionIndex,
tx_id: &Bytes32
) -> Result<Option<Bytes32>, Error>
pub fn update_tx_status(
&self,
tx_id: &Bytes32,
status: TransactionStatus
) -> Result<Option<TransactionStatus>, Error>
pub fn get_tx_status(
&self,
tx_id: &Bytes32
) -> Result<Option<TransactionStatus>, Error>
Trait Implementations
sourceimpl AsMut<Database> for DatabaseTransaction
impl AsMut<Database> for DatabaseTransaction
sourceimpl AsRef<Database> for DatabaseTransaction
impl AsRef<Database> for DatabaseTransaction
sourceimpl Default for Database
impl Default for Database
Construct an ephemeral database uses rocksdb when rocksdb features are enabled uses in-memory when rocksdb features are disabled
sourceimpl From<&'_ Database> for DatabaseTransaction
impl From<&'_ Database> for DatabaseTransaction
sourceimpl InterpreterStorage for Database
impl InterpreterStorage for Database
sourcefn block_height(&self) -> Result<u32, Error>
fn block_height(&self) -> Result<u32, Error>
Provide the current block height in which the transactions should be executed. Read more
sourcefn block_hash(&self, block_height: u32) -> Result<Bytes32, Error>
fn block_hash(&self, block_height: u32) -> Result<Bytes32, Error>
Provide the block hash from a given height.
sourcefn coinbase(&self) -> Result<Address, Error>
fn coinbase(&self) -> Result<Address, Error>
Provide the coinbase address for the VM instructions implementation.
sourcefn storage_contract(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, Contract>>, Self::DataError>
fn storage_contract(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, Contract>>, Self::DataError>
Fetch a previously inserted contract code from the chain state for a given contract. Read more
sourcefn storage_contract_insert(
&mut self,
id: &ContractId,
contract: &Contract
) -> Result<Option<Contract>, Self::DataError>
fn storage_contract_insert(
&mut self,
id: &ContractId,
contract: &Contract
) -> Result<Option<Contract>, Self::DataError>
Append a contract to the chain, provided its identifier. Read more
sourcefn storage_contract_exists(
&self,
id: &ContractId
) -> Result<bool, Self::DataError>
fn storage_contract_exists(
&self,
id: &ContractId
) -> Result<bool, Self::DataError>
Check if a provided contract exists in the chain.
sourcefn storage_contract_root(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Self::DataError>
fn storage_contract_root(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Self::DataError>
Fetch a previously inserted salt+root tuple from the chain state for a given contract. Read more
sourcefn storage_contract_root_insert(
&mut self,
id: &ContractId,
salt: &Salt,
root: &Bytes32
) -> Result<Option<(Salt, Bytes32)>, Self::DataError>
fn storage_contract_root_insert(
&mut self,
id: &ContractId,
salt: &Salt,
root: &Bytes32
) -> Result<Option<(Salt, Bytes32)>, Self::DataError>
Append the salt+root of a contract that was appended to the chain.
sourcefn merkle_contract_state(
&self,
id: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Self::DataError>
fn merkle_contract_state(
&self,
id: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Self::DataError>
Fetch the value form a key-value mapping in a contract storage.
sourcefn merkle_contract_state_insert(
&mut self,
contract: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
fn merkle_contract_state_insert(
&mut self,
contract: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
Insert a key-value mapping in a contract storage.
sourcefn merkle_contract_asset_id_balance(
&self,
id: &ContractId,
asset_id: &AssetId
) -> Result<Option<u64>, Self::DataError>
fn merkle_contract_asset_id_balance(
&self,
id: &ContractId,
asset_id: &AssetId
) -> Result<Option<u64>, Self::DataError>
Fetch the balance of an asset ID in a contract storage.
sourcefn merkle_contract_asset_id_balance_insert(
&mut self,
contract: &ContractId,
asset_id: &AssetId,
value: u64
) -> Result<Option<u64>, Self::DataError>
fn merkle_contract_asset_id_balance_insert(
&mut self,
contract: &ContractId,
asset_id: &AssetId,
value: u64
) -> Result<Option<u64>, Self::DataError>
Update the balance of an asset ID in a contract storage.
sourceimpl MerkleStorage<ContractId, AssetId, u64> for Database
impl MerkleStorage<ContractId, AssetId, u64> for Database
sourcefn insert(
&mut self,
parent: &ContractId,
key: &AssetId,
value: &Word
) -> Result<Option<Word>, Error>
fn insert(
&mut self,
parent: &ContractId,
key: &AssetId,
value: &Word
) -> Result<Option<Word>, Error>
Append P->K->V mapping to the storage. Read more
sourcefn remove(
&mut self,
parent: &ContractId,
key: &AssetId
) -> Result<Option<Word>, Error>
fn remove(
&mut self,
parent: &ContractId,
key: &AssetId
) -> Result<Option<Word>, Error>
Remove P->K->V mapping from the storage. Read more
sourcefn get(
&self,
parent: &ContractId,
key: &AssetId
) -> Result<Option<Cow<'_, Word>>, Error>
fn get(
&self,
parent: &ContractId,
key: &AssetId
) -> Result<Option<Cow<'_, Word>>, Error>
Retrieve Cow<V> such as P->K->V.
sourcefn contains_key(
&self,
parent: &ContractId,
key: &AssetId
) -> Result<bool, Error>
fn contains_key(
&self,
parent: &ContractId,
key: &AssetId
) -> Result<bool, Error>
Return true if there is a P->K mapping to a value in the storage.
sourcefn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Error>
fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Error>
Return the merkle root of the domain of P. Read more
sourceimpl MerkleStorage<ContractId, Bytes32, Bytes32> for Database
impl MerkleStorage<ContractId, Bytes32, Bytes32> for Database
sourcefn insert(
&mut self,
parent: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Error>
fn insert(
&mut self,
parent: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Error>
Append P->K->V mapping to the storage. Read more
sourcefn remove(
&mut self,
parent: &ContractId,
key: &Bytes32
) -> Result<Option<Bytes32>, Error>
fn remove(
&mut self,
parent: &ContractId,
key: &Bytes32
) -> Result<Option<Bytes32>, Error>
Remove P->K->V mapping from the storage. Read more
sourcefn get(
&self,
parent: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Error>
fn get(
&self,
parent: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Error>
Retrieve Cow<V> such as P->K->V.
sourcefn contains_key(
&self,
parent: &ContractId,
key: &Bytes32
) -> Result<bool, Error>
fn contains_key(
&self,
parent: &ContractId,
key: &Bytes32
) -> Result<bool, Error>
Return true if there is a P->K mapping to a value in the storage.
sourcefn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Error>
fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Error>
Return the merkle root of the domain of P. Read more
sourceimpl Storage<Bytes32, FuelBlockDb> for Database
impl Storage<Bytes32, FuelBlockDb> for Database
type Error = KvStoreError
type Error = KvStoreError
Error implementation of the storage functions
sourcefn insert(
&mut self,
key: &Bytes32,
value: &FuelBlockDb
) -> Result<Option<FuelBlockDb>, KvStoreError>
fn insert(
&mut self,
key: &Bytes32,
value: &FuelBlockDb
) -> Result<Option<FuelBlockDb>, KvStoreError>
Append K->V mapping to the storage. Read more
sourcefn remove(&mut self, key: &Bytes32) -> Result<Option<FuelBlockDb>, KvStoreError>
fn remove(&mut self, key: &Bytes32) -> Result<Option<FuelBlockDb>, KvStoreError>
Remove K->V mapping from the storage. Read more
sourcefn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, FuelBlockDb>>, KvStoreError>
fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, FuelBlockDb>>, KvStoreError>
Retrieve Cow<V> such as K->V.
sourcefn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
Return true if there is a K mapping to a value in the storage.
sourceimpl Storage<Bytes32, Transaction> for Database
impl Storage<Bytes32, Transaction> for Database
type Error = KvStoreError
type Error = KvStoreError
Error implementation of the storage functions
sourcefn insert(
&mut self,
key: &Bytes32,
value: &Transaction
) -> Result<Option<Transaction>, KvStoreError>
fn insert(
&mut self,
key: &Bytes32,
value: &Transaction
) -> Result<Option<Transaction>, KvStoreError>
Append K->V mapping to the storage. Read more
sourcefn remove(&mut self, key: &Bytes32) -> Result<Option<Transaction>, KvStoreError>
fn remove(&mut self, key: &Bytes32) -> Result<Option<Transaction>, KvStoreError>
Remove K->V mapping from the storage. Read more
sourcefn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, Transaction>>, KvStoreError>
fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, Transaction>>, KvStoreError>
Retrieve Cow<V> such as K->V.
sourcefn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
Return true if there is a K mapping to a value in the storage.
sourceimpl Storage<Bytes32, Vec<Receipt, Global>> for Database
impl Storage<Bytes32, Vec<Receipt, Global>> for Database
type Error = KvStoreError
type Error = KvStoreError
Error implementation of the storage functions
sourcefn insert(
&mut self,
key: &Bytes32,
value: &Vec<Receipt>
) -> Result<Option<Vec<Receipt>>, KvStoreError>
fn insert(
&mut self,
key: &Bytes32,
value: &Vec<Receipt>
) -> Result<Option<Vec<Receipt>>, KvStoreError>
Append K->V mapping to the storage. Read more
sourcefn remove(
&mut self,
key: &Bytes32
) -> Result<Option<Vec<Receipt>>, KvStoreError>
fn remove(
&mut self,
key: &Bytes32
) -> Result<Option<Vec<Receipt>>, KvStoreError>
Remove K->V mapping from the storage. Read more
sourcefn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, Vec<Receipt>>>, KvStoreError>
fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, Vec<Receipt>>>, KvStoreError>
Retrieve Cow<V> such as K->V.
sourcefn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
Return true if there is a K mapping to a value in the storage.
sourceimpl Storage<ContractId, (Salt, Bytes32)> for Database
impl Storage<ContractId, (Salt, Bytes32)> for Database
sourcefn insert(
&mut self,
key: &ContractId,
value: &(Salt, Bytes32)
) -> Result<Option<(Salt, Bytes32)>, Error>
fn insert(
&mut self,
key: &ContractId,
value: &(Salt, Bytes32)
) -> Result<Option<(Salt, Bytes32)>, Error>
Append K->V mapping to the storage. Read more
sourcefn remove(&mut self, key: &ContractId) -> Result<Option<(Salt, Bytes32)>, Error>
fn remove(&mut self, key: &ContractId) -> Result<Option<(Salt, Bytes32)>, Error>
Remove K->V mapping from the storage. Read more
sourcefn get(
&self,
key: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Error>
fn get(
&self,
key: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Error>
Retrieve Cow<V> such as K->V.
sourcefn contains_key(&self, key: &ContractId) -> Result<bool, Error>
fn contains_key(&self, key: &ContractId) -> Result<bool, Error>
Return true if there is a K mapping to a value in the storage.
sourceimpl Storage<ContractId, Contract> for Database
impl Storage<ContractId, Contract> for Database
sourcefn insert(
&mut self,
key: &ContractId,
value: &Contract
) -> Result<Option<Contract>, Error>
fn insert(
&mut self,
key: &ContractId,
value: &Contract
) -> Result<Option<Contract>, Error>
Append K->V mapping to the storage. Read more
sourcefn remove(&mut self, key: &ContractId) -> Result<Option<Contract>, Error>
fn remove(&mut self, key: &ContractId) -> Result<Option<Contract>, Error>
Remove K->V mapping from the storage. Read more
sourcefn get(&self, key: &ContractId) -> Result<Option<Cow<'_, Contract>>, Error>
fn get(&self, key: &ContractId) -> Result<Option<Cow<'_, Contract>>, Error>
Retrieve Cow<V> such as K->V.
sourcefn contains_key(&self, key: &ContractId) -> Result<bool, Error>
fn contains_key(&self, key: &ContractId) -> Result<bool, Error>
Return true if there is a K mapping to a value in the storage.
sourceimpl Storage<ContractId, UtxoId> for Database
impl Storage<ContractId, UtxoId> for Database
sourcefn insert(
&mut self,
key: &ContractId,
value: &UtxoId
) -> Result<Option<UtxoId>, Self::Error>
fn insert(
&mut self,
key: &ContractId,
value: &UtxoId
) -> Result<Option<UtxoId>, Self::Error>
Append K->V mapping to the storage. Read more
sourcefn remove(&mut self, key: &ContractId) -> Result<Option<UtxoId>, Self::Error>
fn remove(&mut self, key: &ContractId) -> Result<Option<UtxoId>, Self::Error>
Remove K->V mapping from the storage. Read more
sourcefn get<'a>(
&'a self,
key: &ContractId
) -> Result<Option<Cow<'a, UtxoId>>, Self::Error>
fn get<'a>(
&'a self,
key: &ContractId
) -> Result<Option<Cow<'a, UtxoId>>, Self::Error>
Retrieve Cow<V> such as K->V.
sourcefn contains_key(&self, key: &ContractId) -> Result<bool, Self::Error>
fn contains_key(&self, key: &ContractId) -> Result<bool, Self::Error>
Return true if there is a K mapping to a value in the storage.
sourceimpl Storage<UtxoId, Coin> for Database
impl Storage<UtxoId, Coin> for Database
type Error = KvStoreError
type Error = KvStoreError
Error implementation of the storage functions
sourcefn insert(
&mut self,
key: &UtxoId,
value: &Coin
) -> Result<Option<Coin>, KvStoreError>
fn insert(
&mut self,
key: &UtxoId,
value: &Coin
) -> Result<Option<Coin>, KvStoreError>
Append K->V mapping to the storage. Read more
sourcefn remove(&mut self, key: &UtxoId) -> Result<Option<Coin>, KvStoreError>
fn remove(&mut self, key: &UtxoId) -> Result<Option<Coin>, KvStoreError>
Remove K->V mapping from the storage. Read more
sourcefn get(&self, key: &UtxoId) -> Result<Option<Cow<'_, Coin>>, KvStoreError>
fn get(&self, key: &UtxoId) -> Result<Option<Cow<'_, Coin>>, KvStoreError>
Retrieve Cow<V> such as K->V.
sourcefn contains_key(&self, key: &UtxoId) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &UtxoId) -> Result<bool, KvStoreError>
Return true if there is a K mapping to a value in the storage.
sourceimpl TxPoolDb for Database
impl TxPoolDb for Database
fn transaction(
&self,
tx_hash: Bytes32
) -> Result<Option<Arc<Transaction>>, KvStoreError>
fn contract_exist(&self, contract_id: ContractId) -> Result<bool, Error>
impl Send for Database
impl Sync for Database
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more