pub struct Database { /* private fields */ }

Implementations§

source§

impl Database

source

pub fn latest_height(&self) -> StorageResult<BlockHeight>

source

pub fn get_current_block( &self ) -> StorageResult<Option<Cow<'_, CompressedBlock>>>

Get the current block at the head of the chain.

source

pub fn block_time(&self, height: &BlockHeight) -> StorageResult<Tai64>

source

pub fn get_block_id( &self, height: &BlockHeight ) -> StorageResult<Option<BlockId>>

source

pub fn all_block_ids( &self, start: Option<BlockHeight>, direction: IterDirection ) -> impl Iterator<Item = DatabaseResult<(BlockHeight, BlockId)>> + '_

source

pub fn ids_of_genesis_block(&self) -> DatabaseResult<(BlockHeight, BlockId)>

source

pub fn ids_of_latest_block( &self ) -> DatabaseResult<Option<(BlockHeight, BlockId)>>

source§

impl Database

source

pub fn get_contract_config_by_id( &self, contract_id: ContractId ) -> StorageResult<ContractConfig>

source

pub fn contract_balances( &self, contract: ContractId, start_asset: Option<AssetId>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<(AssetId, Word)>> + '_

source

pub fn get_contract_config(&self) -> StorageResult<Option<Vec<ContractConfig>>>

source§

impl Database

source

pub fn owned_message_ids( &self, owner: &Address, start_message_id: Option<MessageId>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<MessageId>> + '_

source

pub fn all_messages( &self, start: Option<MessageId>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<CompressedMessage>> + '_

source

pub fn get_message_config(&self) -> StorageResult<Option<Vec<MessageConfig>>>

source

pub fn is_message_spent(&self, message_id: &MessageId) -> StorageResult<bool>

source

pub fn message_status( &self, message_id: &MessageId ) -> StorageResult<MessageStatus>

source§

impl Database

source

pub fn get_sealed_block_by_id( &self, block_id: &BlockId ) -> StorageResult<Option<SealedBlock>>

source

pub fn get_sealed_block_by_height( &self, height: &BlockHeight ) -> StorageResult<Option<SealedBlock>>

Returns SealedBlock by height. Reusable across different trait implementations

source

pub fn get_genesis(&self) -> StorageResult<Genesis>

source

pub fn get_sealed_block_header_by_height( &self, height: &BlockHeight ) -> StorageResult<Option<SealedBlockHeader>>

source

pub fn get_sealed_block_header( &self, block_id: &BlockId ) -> StorageResult<Option<SealedBlockHeader>>

source

pub fn get_transactions_on_block( &self, block_id: &BlockId ) -> StorageResult<Option<Vec<Transaction>>>

source§

impl Database

source

pub fn owned_coins_ids( &self, owner: &Address, start_coin: Option<UtxoId>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<UtxoId>> + '_

source

pub fn get_coin_config(&self) -> DatabaseResult<Option<Vec<CoinConfig>>>

source§

impl Database

source

pub fn init(&self, config: &ChainConfig) -> DatabaseResult<()>

Ensures the database is initialized and that the database version is correct

source

pub fn get_chain_name(&self) -> DatabaseResult<Option<String>>

source§

impl Database

source

pub fn all_transactions( &self, start: Option<&Bytes32>, direction: Option<IterDirection> ) -> impl Iterator<Item = DatabaseResult<Transaction>> + '_

source

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.

source

pub fn record_tx_id_owner( &self, owner: &Address, block_height: BlockHeight, tx_idx: TransactionIndex, tx_id: &Bytes32 ) -> DatabaseResult<Option<Bytes32>>

source

pub fn update_tx_status( &self, id: &Bytes32, status: TransactionStatus ) -> DatabaseResult<Option<TransactionStatus>>

source

pub fn get_tx_status( &self, id: &Bytes32 ) -> DatabaseResult<Option<TransactionStatus>>

source§

impl Database

source

pub fn new(data_source: DataSource) -> Self

source

pub fn open(path: &Path, capacity: impl Into<Option<usize>>) -> Result<Self>

source

pub fn in_memory() -> Self

source

pub fn transaction(&self) -> DatabaseTransaction

Trait Implementations§

source§

impl AsMut<Database> for DatabaseTransaction

source§

fn as_mut(&mut self) -> &mut Database

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<Database> for Database

source§

fn as_ref(&self) -> &Database

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<Database> for DatabaseTransaction

source§

fn as_ref(&self) -> &Database

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl BlockProducerDatabase for Database

source§

fn get_block( &self, height: &BlockHeight ) -> StorageResult<Cow<'_, CompressedBlock>>

Gets the committed block at the height.
source§

fn block_header_merkle_root( &self, height: &BlockHeight ) -> StorageResult<Bytes32>

Gets the block header BMT MMR root at height.
source§

fn current_block_height(&self) -> StorageResult<BlockHeight>

Fetch the current block height.
source§

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>>>

Returns all unspent coin configs available in the database.
source§

fn get_contract_config(&self) -> StorageResult<Option<Vec<ContractConfig>>>

Returns alive contract configs available in the database.
source§

fn get_message_config(&self) -> StorageResult<Option<Vec<MessageConfig>>>

Returns all unspent message configs available in the database.
source§

fn get_block_height(&self) -> StorageResult<BlockHeight>

Returns the last available block height.
source§

impl Clone for Database

source§

fn clone(&self) -> Database

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl ContractStorageTrait for Database

Implemented to satisfy: GenesisCommitment for ContractRef<&'a mut Database>

source§

impl Database for Database

source§

fn block_header(&self, height: &BlockHeight) -> StorageResult<BlockHeader>

Gets the block header at height.
source§

fn block_header_merkle_root( &self, height: &BlockHeight ) -> StorageResult<Bytes32>

Gets the block header BMT MMR root at height.
source§

impl DatabaseBlocks for Database

source§

impl DatabaseChain for Database

source§

impl DatabaseCoins for Database

source§

fn owned_coins_ids( &self, owner: &Address, start_coin: Option<UtxoId>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<UtxoId>>

source§

impl DatabaseContracts for Database

source§

fn contract_balances( &self, contract: ContractId, start_asset: Option<AssetId>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<ContractBalance>>

source§

impl DatabaseMessages for Database

source§

fn owned_message_ids( &self, owner: &Address, start_message_id: Option<MessageId>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<MessageId>>

source§

fn all_messages( &self, start_message_id: Option<MessageId>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<Message>>

source§

impl DatabaseTransactions for Database

source§

fn tx_status(&self, tx_id: &TxId) -> StorageResult<TransactionStatus>

source§

fn owned_transactions_ids( &self, owner: Address, start: Option<TxPointer>, direction: IterDirection ) -> BoxedIter<'_, StorageResult<(TxPointer, TxId)>>

source§

impl Debug for Database

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Database

Construct an ephemeral database uses rocksdb when rocksdb features are enabled uses in-memory when rocksdb features are disabled

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl ExecutorDatabase for Database

source§

fn seal_block( &mut self, block_id: &BlockId, consensus: &Consensus ) -> StorageResult<Option<Consensus>>

Assigns the Consensus data to the block under the block_id. Return the previous value at the height, if any.
source§

impl From<&Database> for DatabaseTransaction

source§

fn from(source: &Database) -> Self

Converts to this type from the input type.
source§

impl ImporterDatabase for Database

source§

fn latest_block_height(&self) -> StorageResult<BlockHeight>

Returns the latest block height.
source§

impl MerkleRootStorage<BlockHeight, FuelBlocks> for Database

source§

fn root(&self, key: &BlockHeight) -> Result<MerkleRoot, Self::Error>

Return the merkle root of the stored Type in the storage. Read more
source§

impl MerkleRootStorage<ContractId, ContractsAssets> for Database

source§

fn root(&self, _: &ContractId) -> Result<MerkleRoot, Self::Error>

Return the merkle root of the stored Type in the storage. Read more
source§

impl MerkleRootStorage<ContractId, ContractsState> for Database

source§

fn root(&self, _: &ContractId) -> Result<MerkleRoot, Self::Error>

Return the merkle root of the stored Type in the storage. Read more
source§

impl StorageInspect<Coins> for Database

§

type Error = Error

source§

fn get( &self, key: &UtxoId ) -> Result<Option<Cow<'_, CompressedCoin>>, Self::Error>

Retrieve Cow<Value> such as Key->Value.
source§

fn contains_key(&self, key: &UtxoId) -> Result<bool, Self::Error>

Return true if there is a Key mapping to a value in the storage.
source§

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>

Retrieve Cow<Value> such as Key->Value.
source§

fn contains_key( &self, key: &<ContractsAssets as Mappable>::Key ) -> Result<bool, Self::Error>

Return true if there is a Key mapping to a value in the storage.
source§

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>

Retrieve Cow<Value> such as Key->Value.
source§

fn contains_key( &self, key: &<ContractsRawCode as Mappable>::Key ) -> Result<bool, Self::Error>

Return true if there is a Key mapping to a value in the storage.
source§

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>

Retrieve Cow<Value> such as Key->Value.
source§

fn contains_key( &self, key: &<ContractsState as Mappable>::Key ) -> Result<bool, Self::Error>

Return true if there is a Key mapping to a value in the storage.
source§

impl StorageInspect<FuelBlocks> for Database

§

type Error = Error

source§

fn get( &self, key: &BlockId ) -> Result<Option<Cow<'_, CompressedBlock>>, Self::Error>

Retrieve Cow<Value> such as Key->Value.
source§

fn contains_key(&self, key: &BlockId) -> Result<bool, Self::Error>

Return true if there is a Key mapping to a value in the storage.
source§

impl StorageInspect<Messages> for Database

§

type Error = Error

source§

fn get( &self, key: &MessageId ) -> Result<Option<Cow<'_, CompressedMessage>>, Self::Error>

Retrieve Cow<Value> such as Key->Value.
source§

fn contains_key(&self, key: &MessageId) -> Result<bool, Self::Error>

Return true if there is a Key mapping to a value in the storage.
source§

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>>>

Retrieve Cow<Value> such as Key->Value.
source§

fn contains_key(&self, key: &T::Key) -> StorageResult<bool>

Return true if there is a Key mapping to a value in the storage.
source§

impl StorageMutate<Coins> for Database

source§

fn insert( &mut self, key: &UtxoId, value: &CompressedCoin ) -> Result<Option<CompressedCoin>, Self::Error>

Append Key->Value mapping to the storage. Read more
source§

fn remove( &mut self, key: &UtxoId ) -> Result<Option<CompressedCoin>, Self::Error>

Remove Key->Value mapping from the storage. Read more
source§

impl StorageMutate<ContractsAssets> for Database

source§

fn insert( &mut self, key: &<ContractsAssets as Mappable>::Key, value: &<ContractsAssets as Mappable>::Value ) -> Result<Option<<ContractsAssets as Mappable>::OwnedValue>, Self::Error>

Append Key->Value mapping to the storage. Read more
source§

fn remove( &mut self, key: &<ContractsAssets as Mappable>::Key ) -> Result<Option<<ContractsAssets as Mappable>::OwnedValue>, Self::Error>

Remove Key->Value mapping from the storage. Read more
source§

impl StorageMutate<ContractsRawCode> for Database

source§

fn insert( &mut self, key: &<ContractsRawCode as Mappable>::Key, value: &<ContractsRawCode as Mappable>::Value ) -> Result<Option<<ContractsRawCode as Mappable>::OwnedValue>, Self::Error>

Append Key->Value mapping to the storage. Read more
source§

fn remove( &mut self, key: &<ContractsRawCode as Mappable>::Key ) -> Result<Option<<ContractsRawCode as Mappable>::OwnedValue>, Self::Error>

Remove Key->Value mapping from the storage. Read more
source§

impl StorageMutate<ContractsState> for Database

source§

fn insert( &mut self, key: &<ContractsState as Mappable>::Key, value: &<ContractsState as Mappable>::Value ) -> Result<Option<<ContractsState as Mappable>::OwnedValue>, Self::Error>

Append Key->Value mapping to the storage. Read more
source§

fn remove( &mut self, key: &<ContractsState as Mappable>::Key ) -> Result<Option<<ContractsState as Mappable>::OwnedValue>, Self::Error>

Remove Key->Value mapping from the storage. Read more
source§

impl StorageMutate<FuelBlocks> for Database

source§

fn insert( &mut self, key: &BlockId, value: &CompressedBlock ) -> Result<Option<CompressedBlock>, Self::Error>

Append Key->Value mapping to the storage. Read more
source§

fn remove( &mut self, key: &BlockId ) -> Result<Option<CompressedBlock>, Self::Error>

Remove Key->Value mapping from the storage. Read more
source§

impl StorageMutate<Messages> for Database

source§

fn insert( &mut self, key: &MessageId, value: &CompressedMessage ) -> Result<Option<CompressedMessage>, Self::Error>

Append Key->Value mapping to the storage. Read more
source§

fn remove( &mut self, key: &MessageId ) -> Result<Option<CompressedMessage>, Self::Error>

Remove Key->Value mapping from the storage. Read more
source§

impl<T> StorageMutate<T> for Databasewhere T: Mappable + DatabaseColumn, T::Key: ToDatabaseKey, T::Value: Serialize, T::OwnedValue: DeserializeOwned,

source§

fn insert( &mut self, key: &T::Key, value: &T::Value ) -> StorageResult<Option<T::OwnedValue>>

Append Key->Value mapping to the storage. Read more
source§

fn remove(&mut self, key: &T::Key) -> StorageResult<Option<T::OwnedValue>>

Remove Key->Value mapping from the storage. Read more
source§

impl Transaction<Database> for DatabaseTransaction

source§

fn commit(&mut self) -> StorageResult<()>

Commits the pending state changes into the storage.
source§

impl Transactional for Database

§

type Storage = Database

The storage used when creating the transaction.
source§

fn transaction(&self) -> StorageTransaction<Database>

Creates and returns the storage transaction.
source§

impl TxPoolDb for Database

source§

fn utxo(&self, utxo_id: &UtxoId) -> StorageResult<Option<CompressedCoin>>

source§

fn contract_exist(&self, contract_id: &ContractId) -> StorageResult<bool>

source§

fn message( &self, message_id: &MessageId ) -> StorageResult<Option<CompressedMessage>>

source§

fn is_message_spent(&self, message_id: &MessageId) -> StorageResult<bool>

source§

fn current_block_height(&self) -> StorageResult<BlockHeight>

source§

impl DatabasePort for Database

source§

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
source§

impl Sync for Database

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyDebug for Twhere T: Any + Debug,

§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Returns a reference to the underlying type as Any.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<T> StorageAsMut for T

§

fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where Type: Mappable,

§

fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where Type: Mappable,

§

impl<T> StorageAsRef for T

§

fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where Type: Mappable,

§

fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where Type: Mappable,

§

impl<S, Type> StorageInspectInfallible<Type> for Swhere S: StorageInspect<Type, Error = Infallible>, Type: Mappable,

§

fn get( &self, key: &<Type as Mappable>::Key ) -> Option<Cow<'_, <Type as Mappable>::OwnedValue>>

§

fn contains_key(&self, key: &<Type as Mappable>::Key) -> bool

§

impl<S, Type> StorageMutateInfallible<Type> for Swhere S: StorageMutate<Type, Error = Infallible>, Type: Mappable,

§

fn insert( &mut self, key: &<Type as Mappable>::Key, value: &<Type as Mappable>::Value ) -> Option<<Type as Mappable>::OwnedValue>

§

fn remove( &mut self, key: &<Type as Mappable>::Key ) -> Option<<Type as Mappable>::OwnedValue>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more