pub struct Database { /* private fields */ }
Implementations§
source§impl Database
impl Database
pub fn get_block_height(&self) -> Result<Option<BlockHeight>, Error>
sourcepub fn get_current_block(&self) -> Result<Option<Cow<'_, FuelBlockDb>>, Error>
pub fn get_current_block(&self) -> Result<Option<Cow<'_, FuelBlockDb>>, Error>
Get the current block at the head of the chain.
pub fn block_time(&self, height: u32) -> Result<Tai64, 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>> + '_
pub fn genesis_block_ids(&self) -> Result<(BlockHeight, Bytes32), Error>
source§impl Database
impl Database
pub fn owned_coins_ids(
&self,
owner: &Address,
start_coin: Option<UtxoId>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<UtxoId, Error>> + '_
pub fn get_coin_config(&self) -> Result<Option<Vec<CoinConfig>>>
source§impl Database
impl Database
pub fn contract_balances(
&self,
contract: ContractId,
start_asset: Option<AssetId>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<(AssetId, Word), Error>> + '_
pub fn get_contract_config(&self) -> Result<Option<Vec<ContractConfig>>, Error>
source§impl Database
impl Database
pub fn owned_message_ids(
&self,
owner: &Address,
start_message_id: Option<MessageId>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<MessageId, Error>> + '_
pub fn all_messages(
&self,
start: Option<MessageId>,
direction: Option<IterDirection>
) -> impl Iterator<Item = Result<Message, Error>> + '_
pub fn get_message_config(&self) -> Result<Option<Vec<MessageConfig>>, Error>
source§impl Database
impl Database
pub fn get_sealed_block(
&self,
block_id: &Bytes32
) -> Result<Option<SealedFuelBlock>, KvStoreError>
pub fn get_genesis(&self) -> Result<Genesis, KvStoreError>
pub fn get_sealed_block_header(
&self,
block_id: &Bytes32
) -> Result<Option<SealedFuelBlockHeader>, KvStoreError>
source§impl Database
impl Database
pub fn init(&self, config: &ChainConfig) -> Result<(), Error>
pub fn get_chain_name(&self) -> Result<Option<String>, Error>
pub fn get_starting_chain_height(&self) -> Result<Option<BlockHeight>, Error>
source§impl 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,
id: &Bytes32,
status: TransactionStatus
) -> Result<Option<TransactionStatus>, Error>
pub fn get_tx_status(
&self,
id: &Bytes32
) -> Result<Option<TransactionStatus>, Error>
Trait Implementations§
source§impl AsMut<Database> for DatabaseTransaction
impl AsMut<Database> for DatabaseTransaction
source§impl AsRef<Database> for DatabaseTransaction
impl AsRef<Database> for DatabaseTransaction
source§impl BlockDb for Database
impl BlockDb for Database
fn block_height(&self) -> Result<BlockHeight>
fn seal_block(
&mut self,
block_id: BlockId,
consensus: FuelBlockConsensus
) -> Result<()>
source§impl BlockProducer<Database> for PoACoordinatorAdapter
impl BlockProducer<Database> for PoACoordinatorAdapter
fn produce_and_execute_block<'life0, 'async_trait>(
&'life0 self,
height: BlockHeight,
max_gas: Word
) -> Pin<Box<dyn Future<Output = Result<UncommittedResult<DBTransaction<Database>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn dry_run<'life0, 'async_trait>(
&'life0 self,
transaction: Transaction,
height: Option<BlockHeight>,
utxo_validation: Option<bool>
) -> Pin<Box<dyn Future<Output = Result<Vec<Receipt>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§impl BlockProducerDatabase for Database
impl BlockProducerDatabase for Database
source§fn get_block(
&self,
fuel_height: BlockHeight
) -> Result<Option<Cow<'_, FuelBlockDb>>>
fn get_block(
&self,
fuel_height: BlockHeight
) -> Result<Option<Cow<'_, FuelBlockDb>>>
Fetch previously committed block at given height.
source§fn current_block_height(&self) -> Result<BlockHeight>
fn current_block_height(&self) -> Result<BlockHeight>
Fetch the current block height.
source§impl ChainConfigDb for Database
impl ChainConfigDb for Database
Implement ChainConfigDb
so that Database
can be passed to
StateConfig's
generate_state_config()
method
source§fn get_coin_config(&self) -> Result<Option<Vec<CoinConfig>>>
fn get_coin_config(&self) -> Result<Option<Vec<CoinConfig>>>
Returns all unspent coin configs available in the database.
source§fn get_contract_config(&self) -> Result<Option<Vec<ContractConfig>>, Error>
fn get_contract_config(&self) -> Result<Option<Vec<ContractConfig>>, Error>
Returns alive contract configs available in the database.
source§fn get_message_config(&self) -> Result<Option<Vec<MessageConfig>>, Error>
fn get_message_config(&self) -> Result<Option<Vec<MessageConfig>>, Error>
Returns all unspent message configs available in the database.
source§fn get_block_height(&self) -> Result<Option<BlockHeight>, Error>
fn get_block_height(&self) -> Result<Option<BlockHeight>, Error>
Returns the last available block height.
source§impl ContractStorageTrait<'_> for Database
impl ContractStorageTrait<'_> for Database
Implemented to satisfy: GenesisCommitment for ContractRef<&'a mut Database>
type InnerError = Error
source§impl 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
source§impl Executor<Database> for Executor
impl Executor<Database> for Executor
source§fn execute_without_commit(
&self,
block: ExecutionBlock
) -> Result<UncommittedResult<DBTransaction<Database>>, Error>
fn execute_without_commit(
&self,
block: ExecutionBlock
) -> Result<UncommittedResult<DBTransaction<Database>>, Error>
Executes the block and returns the result of execution with uncommitted database
transaction.
source§fn dry_run(
&self,
block: ExecutionBlock,
utxo_validation: Option<bool>
) -> Result<Vec<Vec<Receipt>>, Error>
fn dry_run(
&self,
block: ExecutionBlock,
utxo_validation: Option<bool>
) -> Result<Vec<Vec<Receipt>>, Error>
Executes the block without committing it to the database. During execution collects the
receipts to return them. The
utxo_validation
field can be used to disable the validation
of utxos during execution.source§impl Executor<Database> for ExecutorAdapter
impl Executor<Database> for ExecutorAdapter
source§fn execute_without_commit(
&self,
block: ExecutionBlock
) -> Result<UncommittedResult<DBTransaction<Database>>, Error>
fn execute_without_commit(
&self,
block: ExecutionBlock
) -> Result<UncommittedResult<DBTransaction<Database>>, Error>
Executes the block and returns the result of execution with uncommitted database
transaction.
source§fn dry_run(
&self,
block: ExecutionBlock,
utxo_validation: Option<bool>
) -> Result<Vec<Vec<Receipt>>, Error>
fn dry_run(
&self,
block: ExecutionBlock,
utxo_validation: Option<bool>
) -> Result<Vec<Vec<Receipt>>, Error>
Executes the block without committing it to the database. During execution collects the
receipts to return them. The
utxo_validation
field can be used to disable the validation
of utxos during execution.source§impl From<&Database> for DatabaseTransaction
impl From<&Database> for DatabaseTransaction
source§impl P2pDb for Database
impl P2pDb for Database
fn get_sealed_block<'life0, 'async_trait>(
&'life0 self,
height: BlockHeight
) -> Pin<Box<dyn Future<Output = Option<Arc<SealedFuelBlock>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§impl RelayerDb for Database
impl RelayerDb for Database
source§fn get_chain_height<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = BlockHeight> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_chain_height<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = BlockHeight> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
current best block number
fn get_sealed_block<'life0, 'async_trait>(
&'life0 self,
height: BlockHeight
) -> Pin<Box<dyn Future<Output = Option<Arc<SealedFuelBlock>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn set_finalized_da_height<'life0, 'async_trait>(
&'life0 self,
block: DaBlockHeight
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_finalized_da_height<'life0, 'async_trait>(
&'life0 self,
block: DaBlockHeight
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
set finalized da height that represent last block from da layer that got finalized.
source§fn get_finalized_da_height<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Option<DaBlockHeight>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_finalized_da_height<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Option<DaBlockHeight>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Assume it is always set as initialization of database.
source§fn get_last_published_fuel_height<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Option<BlockHeight>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_last_published_fuel_height<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Option<BlockHeight>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the last fuel block height that was published to the da layer.
source§fn set_last_published_fuel_height<'life0, 'async_trait>(
&'life0 self,
block_height: BlockHeight
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_last_published_fuel_height<'life0, 'async_trait>(
&'life0 self,
block_height: BlockHeight
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set the last fuel block height that was published to the da layer.
source§fn insert_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 CheckedMessage
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn insert_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: &'life1 CheckedMessage
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Add bridge message to database. Messages are not revertible.
source§impl StorageInspect<Coins> for Database
impl StorageInspect<Coins> for Database
type Error = KvStoreError
source§fn get(&self, key: &UtxoId) -> Result<Option<Cow<'_, Coin>>, KvStoreError>
fn get(&self, key: &UtxoId) -> Result<Option<Cow<'_, Coin>>, KvStoreError>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &UtxoId) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &UtxoId) -> Result<bool, KvStoreError>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<ContractsLatestUtxo> for Database
impl StorageInspect<ContractsLatestUtxo> for Database
source§impl StorageInspect<ContractsState<'_>> for Database
impl StorageInspect<ContractsState<'_>> for Database
source§impl StorageInspect<FuelBlocks> for Database
impl StorageInspect<FuelBlocks> for Database
type Error = KvStoreError
source§fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, FuelBlockDb>>, KvStoreError>
fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, FuelBlockDb>>, KvStoreError>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<Messages> for Database
impl StorageInspect<Messages> for Database
type Error = KvStoreError
source§fn get(&self, key: &MessageId) -> Result<Option<Cow<'_, Message>>, KvStoreError>
fn get(&self, key: &MessageId) -> Result<Option<Cow<'_, Message>>, KvStoreError>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &MessageId) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &MessageId) -> Result<bool, KvStoreError>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<Receipts> for Database
impl StorageInspect<Receipts> for Database
type Error = KvStoreError
source§fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, Vec<Receipt>>>, KvStoreError>
fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, Vec<Receipt>>>, KvStoreError>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<SealedBlockConsensus> for Database
impl StorageInspect<SealedBlockConsensus> for Database
type Error = KvStoreError
source§fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, FuelBlockConsensus>>, KvStoreError>
fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, FuelBlockConsensus>>, KvStoreError>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<Transactions> for Database
impl StorageInspect<Transactions> for Database
type Error = KvStoreError
source§fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, Transaction>>, KvStoreError>
fn get(
&self,
key: &Bytes32
) -> Result<Option<Cow<'_, Transaction>>, KvStoreError>
Retrieve
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
fn contains_key(&self, key: &Bytes32) -> Result<bool, KvStoreError>
Return
true
if there is a Key
mapping to a value in the storage.source§impl StorageMutate<ContractsInfo> for Database
impl StorageMutate<ContractsInfo> for Database
source§impl StorageMutate<ContractsLatestUtxo> for Database
impl StorageMutate<ContractsLatestUtxo> for Database
source§impl StorageMutate<ContractsState<'_>> for Database
impl StorageMutate<ContractsState<'_>> for Database
source§impl StorageMutate<FuelBlocks> for Database
impl StorageMutate<FuelBlocks> for Database
source§fn insert(
&mut self,
key: &Bytes32,
value: &FuelBlockDb
) -> Result<Option<FuelBlockDb>, KvStoreError>
fn insert(
&mut self,
key: &Bytes32,
value: &FuelBlockDb
) -> Result<Option<FuelBlockDb>, KvStoreError>
Append
Key->Value
mapping to the storage. Read moresource§fn remove(&mut self, key: &Bytes32) -> Result<Option<FuelBlockDb>, KvStoreError>
fn remove(&mut self, key: &Bytes32) -> Result<Option<FuelBlockDb>, KvStoreError>
Remove
Key->Value
mapping from the storage. Read moresource§impl StorageMutate<Receipts> for Database
impl StorageMutate<Receipts> for Database
source§impl StorageMutate<SealedBlockConsensus> for Database
impl StorageMutate<SealedBlockConsensus> for Database
source§fn insert(
&mut self,
key: &Bytes32,
value: &FuelBlockConsensus
) -> Result<Option<FuelBlockConsensus>, KvStoreError>
fn insert(
&mut self,
key: &Bytes32,
value: &FuelBlockConsensus
) -> Result<Option<FuelBlockConsensus>, KvStoreError>
Append
Key->Value
mapping to the storage. Read moresource§fn remove(
&mut self,
key: &Bytes32
) -> Result<Option<FuelBlockConsensus>, KvStoreError>
fn remove(
&mut self,
key: &Bytes32
) -> Result<Option<FuelBlockConsensus>, KvStoreError>
Remove
Key->Value
mapping from the storage. Read moresource§impl StorageMutate<Transactions> for Database
impl StorageMutate<Transactions> for Database
source§impl TxPoolDb for Database
impl TxPoolDb for Database
fn current_block_height(&self) -> Result<BlockHeight, KvStoreError>
fn utxo(&self, utxo_id: &UtxoId) -> Result<Option<Coin>, KvStoreError>
fn contract_exist(&self, contract_id: &ContractId) -> Result<bool, Error>
fn message(
&self,
message_id: &MessageId
) -> Result<Option<Message>, KvStoreError>
impl Send for Database
- SAFETY: we are safe to do it because DataSource is Send+Sync and there is nowhere it is overwritten it is not Send+Sync by default because Storage insert fn takes &mut self