use crate::{ database::{ database_description::off_chain::OffChain, Database, }, fuel_core_graphql_api::storage::transactions::{ OwnedTransactionIndexCursor, OwnedTransactionIndexKey, OwnedTransactions, TransactionStatuses, }, }; use fuel_core_storage::{ iter::{ IterDirection, IteratorOverTable, }, tables::Transactions, Result as StorageResult, }; use fuel_core_types::{ self, fuel_tx::{ Bytes32, Transaction, TxPointer, }, fuel_types::Address, services::txpool::TransactionStatus, }; impl Database { pub fn all_transactions( &self, start: Option<&Bytes32>, direction: Option, ) -> impl Iterator> + '_ { self.iter_all_by_start::(start, direction) .map(|res| res.map(|(_, tx)| tx)) } } impl Database { /// 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 owned_transactions( &self, owner: Address, start: Option, direction: Option, ) -> impl Iterator> + '_ { let start = start.map(|cursor| { OwnedTransactionIndexKey::new(&owner, cursor.block_height, cursor.tx_idx) }); self.iter_all_filtered::( Some(owner), start.as_ref(), direction, ) .map(|res| { res.map(|(key, tx_id)| (TxPointer::new(key.block_height, key.tx_idx), tx_id)) }) } pub fn get_tx_status( &self, id: &Bytes32, ) -> StorageResult> { use fuel_core_storage::StorageAsRef; self.storage::() .get(id) .map(|v| v.map(|v| v.into_owned())) } }