pub struct Database { /* private fields */ }
Implementations§
source§impl Database
impl Database
pub fn latest_height(&self) -> StorageResult<BlockHeight>
sourcepub fn get_current_block(
&self
) -> StorageResult<Option<Cow<'_, CompressedBlock>>>
pub fn get_current_block( &self ) -> StorageResult<Option<Cow<'_, CompressedBlock>>>
Get the current block at the head of the chain.
pub fn block_time(&self, height: &BlockHeight) -> StorageResult<Tai64>
pub fn get_block_id( &self, height: &BlockHeight ) -> StorageResult<Option<BlockId>>
pub fn all_block_ids( &self, start: Option<BlockHeight>, direction: IterDirection ) -> impl Iterator<Item = DatabaseResult<(BlockHeight, BlockId)>> + '_
pub fn ids_of_genesis_block(&self) -> DatabaseResult<(BlockHeight, BlockId)>
pub fn ids_of_latest_block( &self ) -> DatabaseResult<Option<(BlockHeight, BlockId)>>
source§impl Database
impl Database
pub fn get_contract_config_by_id( &self, contract_id: ContractId ) -> StorageResult<ContractConfig>
pub fn contract_balances( &self, contract: ContractId, start_asset: Option<AssetId>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<(AssetId, Word)>> + '_
pub fn get_contract_config(&self) -> StorageResult<Option<Vec<ContractConfig>>>
source§impl Database
impl Database
pub fn owned_message_ids( &self, owner: &Address, start_message_id: Option<MessageId>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<MessageId>> + '_
pub fn all_messages( &self, start: Option<MessageId>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<CompressedMessage>> + '_
pub fn get_message_config(&self) -> StorageResult<Option<Vec<MessageConfig>>>
pub fn is_message_spent(&self, message_id: &MessageId) -> StorageResult<bool>
pub fn message_status( &self, message_id: &MessageId ) -> StorageResult<MessageStatus>
source§impl Database
impl Database
pub fn get_sealed_block_by_id( &self, block_id: &BlockId ) -> StorageResult<Option<SealedBlock>>
sourcepub fn get_sealed_block_by_height(
&self,
height: &BlockHeight
) -> StorageResult<Option<SealedBlock>>
pub fn get_sealed_block_by_height( &self, height: &BlockHeight ) -> StorageResult<Option<SealedBlock>>
Returns SealedBlock
by height
.
Reusable across different trait implementations
pub fn get_genesis(&self) -> StorageResult<Genesis>
pub fn get_sealed_block_header_by_height( &self, height: &BlockHeight ) -> StorageResult<Option<SealedBlockHeader>>
pub fn get_sealed_block_header( &self, block_id: &BlockId ) -> StorageResult<Option<SealedBlockHeader>>
pub fn get_transactions_on_block( &self, block_id: &BlockId ) -> StorageResult<Option<Vec<Transaction>>>
source§impl Database
impl Database
pub fn owned_coins_ids( &self, owner: &Address, start_coin: Option<UtxoId>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<UtxoId>> + '_
pub fn get_coin_config(&self) -> DatabaseResult<Option<Vec<CoinConfig>>>
source§impl Database
impl Database
sourcepub fn init(&self, config: &ChainConfig) -> DatabaseResult<()>
pub fn init(&self, config: &ChainConfig) -> DatabaseResult<()>
Ensures the database is initialized and that the database version is correct
pub fn get_chain_name(&self) -> DatabaseResult<Option<String>>
source§impl Database
impl Database
pub fn all_transactions( &self, start: Option<&Bytes32>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<Transaction>> + '_
sourcepub fn owned_transactions(
&self,
owner: Address,
start: Option<OwnedTransactionIndexCursor>,
direction: Option<IterDirection>
) -> impl Iterator<Item = DatabaseResult<(TxPointer, Bytes32)>> + '_
pub fn owned_transactions( &self, owner: Address, start: Option<OwnedTransactionIndexCursor>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<(TxPointer, Bytes32)>> + '_
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 ) -> DatabaseResult<Option<Bytes32>>
pub fn update_tx_status( &self, id: &Bytes32, status: TransactionStatus ) -> DatabaseResult<Option<TransactionStatus>>
pub fn get_tx_status( &self, id: &Bytes32 ) -> DatabaseResult<Option<TransactionStatus>>
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 BlockProducerDatabase for Database
impl BlockProducerDatabase for Database
source§fn get_block(
&self,
height: &BlockHeight
) -> StorageResult<Cow<'_, CompressedBlock>>
fn get_block( &self, height: &BlockHeight ) -> StorageResult<Cow<'_, CompressedBlock>>
height
.source§fn block_header_merkle_root(
&self,
height: &BlockHeight
) -> StorageResult<Bytes32>
fn block_header_merkle_root( &self, height: &BlockHeight ) -> StorageResult<Bytes32>
height
.source§fn current_block_height(&self) -> StorageResult<BlockHeight>
fn current_block_height(&self) -> StorageResult<BlockHeight>
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) -> StorageResult<Option<Vec<CoinConfig>>>
fn get_coin_config(&self) -> StorageResult<Option<Vec<CoinConfig>>>
source§fn get_contract_config(&self) -> StorageResult<Option<Vec<ContractConfig>>>
fn get_contract_config(&self) -> StorageResult<Option<Vec<ContractConfig>>>
source§fn get_message_config(&self) -> StorageResult<Option<Vec<MessageConfig>>>
fn get_message_config(&self) -> StorageResult<Option<Vec<MessageConfig>>>
source§fn get_block_height(&self) -> StorageResult<BlockHeight>
fn get_block_height(&self) -> StorageResult<BlockHeight>
source§impl ContractStorageTrait for Database
impl ContractStorageTrait for Database
Implemented to satisfy: GenesisCommitment for ContractRef<&'a mut Database>
type InnerError = Error
source§impl Database for Database
impl Database for Database
source§fn block_header(&self, height: &BlockHeight) -> StorageResult<BlockHeader>
fn block_header(&self, height: &BlockHeight) -> StorageResult<BlockHeader>
height
.source§fn block_header_merkle_root(
&self,
height: &BlockHeight
) -> StorageResult<Bytes32>
fn block_header_merkle_root( &self, height: &BlockHeight ) -> StorageResult<Bytes32>
height
.source§impl DatabaseBlocks for Database
impl DatabaseBlocks for Database
fn block_id(&self, height: &BlockHeight) -> StorageResult<BlockId>
fn blocks_ids( &self, start: Option<BlockHeight>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<(BlockHeight, BlockId)>>
fn ids_of_latest_block(&self) -> StorageResult<(BlockHeight, BlockId)>
source§impl DatabaseChain for Database
impl DatabaseChain for Database
fn chain_name(&self) -> StorageResult<String>
fn base_chain_height(&self) -> StorageResult<DaBlockHeight>
source§impl DatabaseCoins for Database
impl DatabaseCoins for Database
fn owned_coins_ids( &self, owner: &Address, start_coin: Option<UtxoId>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<UtxoId>>
source§impl DatabaseContracts for Database
impl DatabaseContracts for Database
fn contract_balances( &self, contract: ContractId, start_asset: Option<AssetId>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<ContractBalance>>
source§impl DatabaseMessages for Database
impl DatabaseMessages for Database
fn owned_message_ids( &self, owner: &Address, start_message_id: Option<MessageId>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<MessageId>>
fn all_messages( &self, start_message_id: Option<MessageId>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<Message>>
source§impl DatabaseTransactions for Database
impl DatabaseTransactions for Database
fn tx_status(&self, tx_id: &TxId) -> StorageResult<TransactionStatus>
fn owned_transactions_ids( &self, owner: Address, start: Option<TxPointer>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<(TxPointer, TxId)>>
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 ExecutorDatabase for Database
impl ExecutorDatabase for Database
source§fn seal_block(
&mut self,
block_id: &BlockId,
consensus: &Consensus
) -> StorageResult<Option<Consensus>>
fn seal_block( &mut self, block_id: &BlockId, consensus: &Consensus ) -> StorageResult<Option<Consensus>>
Consensus
data to the block under the block_id
.
Return the previous value at the height
, if any.source§impl From<&Database> for DatabaseTransaction
impl From<&Database> for DatabaseTransaction
source§impl ImporterDatabase for Database
impl ImporterDatabase for Database
source§fn latest_block_height(&self) -> StorageResult<BlockHeight>
fn latest_block_height(&self) -> StorageResult<BlockHeight>
source§impl MerkleRootStorage<BlockHeight, FuelBlocks> for Database
impl MerkleRootStorage<BlockHeight, FuelBlocks> for Database
source§impl StorageInspect<ContractsAssets> for Database
impl StorageInspect<ContractsAssets> for Database
type Error = Error
source§fn get(
&self,
key: &<ContractsAssets as Mappable>::Key
) -> Result<Option<Cow<'_, <ContractsAssets as Mappable>::OwnedValue>>, Self::Error>
fn get( &self, key: &<ContractsAssets as Mappable>::Key ) -> Result<Option<Cow<'_, <ContractsAssets as Mappable>::OwnedValue>>, Self::Error>
Cow<Value>
such as Key->Value
.source§fn contains_key(
&self,
key: &<ContractsAssets as Mappable>::Key
) -> Result<bool, Self::Error>
fn contains_key( &self, key: &<ContractsAssets as Mappable>::Key ) -> Result<bool, Self::Error>
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<ContractsRawCode> for Database
impl StorageInspect<ContractsRawCode> for Database
type Error = Error
source§fn get(
&self,
key: &<ContractsRawCode as Mappable>::Key
) -> Result<Option<Cow<'_, <ContractsRawCode as Mappable>::OwnedValue>>, Self::Error>
fn get( &self, key: &<ContractsRawCode as Mappable>::Key ) -> Result<Option<Cow<'_, <ContractsRawCode as Mappable>::OwnedValue>>, Self::Error>
Cow<Value>
such as Key->Value
.source§fn contains_key(
&self,
key: &<ContractsRawCode as Mappable>::Key
) -> Result<bool, Self::Error>
fn contains_key( &self, key: &<ContractsRawCode as Mappable>::Key ) -> Result<bool, Self::Error>
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<ContractsState> for Database
impl StorageInspect<ContractsState> for Database
type Error = Error
source§fn get(
&self,
key: &<ContractsState as Mappable>::Key
) -> Result<Option<Cow<'_, <ContractsState as Mappable>::OwnedValue>>, Self::Error>
fn get( &self, key: &<ContractsState as Mappable>::Key ) -> Result<Option<Cow<'_, <ContractsState as Mappable>::OwnedValue>>, Self::Error>
Cow<Value>
such as Key->Value
.source§fn contains_key(
&self,
key: &<ContractsState as Mappable>::Key
) -> Result<bool, Self::Error>
fn contains_key( &self, key: &<ContractsState as Mappable>::Key ) -> Result<bool, Self::Error>
true
if there is a Key
mapping to a value in the storage.source§impl StorageInspect<FuelBlocks> for Database
impl StorageInspect<FuelBlocks> for Database
source§impl<T> StorageInspect<T> for Databasewhere
T: Mappable + DatabaseColumn,
T::Key: ToDatabaseKey,
T::OwnedValue: DeserializeOwned,
impl<T> StorageInspect<T> for Databasewhere T: Mappable + DatabaseColumn, T::Key: ToDatabaseKey, T::OwnedValue: DeserializeOwned,
type Error = Error
source§fn get(&self, key: &T::Key) -> StorageResult<Option<Cow<'_, T::OwnedValue>>>
fn get(&self, key: &T::Key) -> StorageResult<Option<Cow<'_, T::OwnedValue>>>
Cow<Value>
such as Key->Value
.source§fn contains_key(&self, key: &T::Key) -> StorageResult<bool>
fn contains_key(&self, key: &T::Key) -> StorageResult<bool>
true
if there is a Key
mapping to a value in the storage.source§impl StorageMutate<Coins> for Database
impl StorageMutate<Coins> for Database
source§fn insert(
&mut self,
key: &UtxoId,
value: &CompressedCoin
) -> Result<Option<CompressedCoin>, Self::Error>
fn insert( &mut self, key: &UtxoId, value: &CompressedCoin ) -> Result<Option<CompressedCoin>, Self::Error>
Key->Value
mapping to the storage. Read moresource§impl StorageMutate<ContractsAssets> for Database
impl StorageMutate<ContractsAssets> for Database
source§impl StorageMutate<ContractsRawCode> for Database
impl StorageMutate<ContractsRawCode> 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: &BlockId,
value: &CompressedBlock
) -> Result<Option<CompressedBlock>, Self::Error>
fn insert( &mut self, key: &BlockId, value: &CompressedBlock ) -> Result<Option<CompressedBlock>, Self::Error>
Key->Value
mapping to the storage. Read moresource§impl StorageMutate<Messages> for Database
impl StorageMutate<Messages> for Database
source§fn insert(
&mut self,
key: &MessageId,
value: &CompressedMessage
) -> Result<Option<CompressedMessage>, Self::Error>
fn insert( &mut self, key: &MessageId, value: &CompressedMessage ) -> Result<Option<CompressedMessage>, Self::Error>
Key->Value
mapping to the storage. Read moresource§impl<T> StorageMutate<T> for Databasewhere
T: Mappable + DatabaseColumn,
T::Key: ToDatabaseKey,
T::Value: Serialize,
T::OwnedValue: DeserializeOwned,
impl<T> StorageMutate<T> for Databasewhere T: Mappable + DatabaseColumn, T::Key: ToDatabaseKey, T::Value: Serialize, T::OwnedValue: DeserializeOwned,
source§impl Transaction<Database> for DatabaseTransaction
impl Transaction<Database> for DatabaseTransaction
source§fn commit(&mut self) -> StorageResult<()>
fn commit(&mut self) -> StorageResult<()>
source§impl Transactional for Database
impl Transactional for Database
source§fn transaction(&self) -> StorageTransaction<Database>
fn transaction(&self) -> StorageTransaction<Database>
source§impl TxPoolDb for Database
impl TxPoolDb for Database
fn utxo(&self, utxo_id: &UtxoId) -> StorageResult<Option<CompressedCoin>>
fn contract_exist(&self, contract_id: &ContractId) -> StorageResult<bool>
fn message( &self, message_id: &MessageId ) -> StorageResult<Option<CompressedMessage>>
fn is_message_spent(&self, message_id: &MessageId) -> StorageResult<bool>
fn current_block_height(&self) -> StorageResult<BlockHeight>
impl DatabasePort for Database
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
impl Sync for Database
Auto Trait Implementations§
Blanket Implementations§
§impl<T> AnyDebug for Twhere
T: Any + Debug,
impl<T> AnyDebug for Twhere T: Any + Debug,
§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Any
.