diff --git a/crates/fuel-core/src/database/block.rs b/crates/fuel-core/src/database/block.rs index 09148d8ee3c..7c9ab130072 100644 --- a/crates/fuel-core/src/database/block.rs +++ b/crates/fuel-core/src/database/block.rs @@ -66,10 +66,8 @@ impl OnChainIterableKeyValueView { /// Retrieve the full block and all associated transactions pub fn get_full_block(&self, height: &BlockHeight) -> StorageResult> { let db_block = self.storage::().get(height)?; + if let Some(block) = db_block { - // fetch all the transactions - // TODO: Use multiget when it's implemented. - // https://github.com/FuelLabs/fuel-core/issues/2344 let transaction_ids = block.transactions().iter().into_boxed(); let txs = >::get_batch( self, @@ -78,17 +76,6 @@ impl OnChainIterableKeyValueView { .map(|res| res.and_then(|opt| opt.ok_or(not_found!(Transactions)))) .try_collect()?; - // let transaction_ids = Box::new(block.transactions().iter()); - // let txs = self - // .storage::() - // .get_multi(transaction_ids) - // .map(|tx| { - // tx.and_then(|tx| { - // tx.ok_or(not_found!(Transactions)).map(Cow::into_owned) - // }) - // }) - // .try_collect()?; - // Ok(Some(block.into_owned().uncompress(txs))) } else { Ok(None) diff --git a/crates/fuel-core/src/graphql_api/database.rs b/crates/fuel-core/src/graphql_api/database.rs index f887d2759c9..470f8f9dd70 100644 --- a/crates/fuel-core/src/graphql_api/database.rs +++ b/crates/fuel-core/src/graphql_api/database.rs @@ -151,8 +151,6 @@ impl ReadView { &self, tx_ids: Vec, ) -> Vec> { - // TODO: Use multiget when it's implemented. - // https://github.com/FuelLabs/fuel-core/issues/2344 let on_chain_results: BTreeMap<_, _> = tx_ids .iter() .enumerate() @@ -178,11 +176,7 @@ impl ReadView { let mut results = on_chain_results; results.extend(off_chain_results); - // let result = tx_ids - // .iter() - // .map(|tx_id| self.transaction(tx_id)) - // .collect::>(); - // Give a chance to other tasks to run. + // Give a chance for other tasks to run. tokio::task::yield_now().await; results.into_values().collect() diff --git a/crates/fuel-core/src/query/coin.rs b/crates/fuel-core/src/query/coin.rs index 5c61fa52c2b..7f8ea37424e 100644 --- a/crates/fuel-core/src/query/coin.rs +++ b/crates/fuel-core/src/query/coin.rs @@ -4,11 +4,8 @@ use fuel_core_storage::{ IntoBoxedIter, IterDirection, }, - // not_found, - // tables::Coins, Error as StorageError, Result as StorageResult, - // StorageAsRef, }; use fuel_core_types::{ entities::coins::coin::Coin, @@ -24,15 +21,6 @@ use futures::{ impl ReadView { pub fn coin(&self, utxo_id: UtxoId) -> StorageResult { self.on_chain.coin(utxo_id) - // let coin = self - // .on_chain - // .as_ref() - // .storage::() - // .get(&utxo_id)? - // .ok_or(not_found!(Coins))? - // .into_owned(); - - // Ok(coin.uncompress(utxo_id)) } pub async fn coins( @@ -40,10 +28,8 @@ impl ReadView { utxo_ids: Vec, ) -> impl Iterator> + '_ { let coins: Vec<_> = self.on_chain.coins(utxo_ids.iter().into_boxed()).collect(); - // TODO: Use multiget when it's implemented. - // https://github.com/FuelLabs/fuel-core/issues/2344 - // let coins = utxo_ids.into_iter().map(|id| self.coin(id)); - // Give a chance to other tasks to run. + + // Give a chance for other tasks to run. tokio::task::yield_now().await; coins.into_iter() } diff --git a/crates/fuel-core/src/query/message.rs b/crates/fuel-core/src/query/message.rs index f66b7e99e4c..625c86e8ecb 100644 --- a/crates/fuel-core/src/query/message.rs +++ b/crates/fuel-core/src/query/message.rs @@ -83,27 +83,14 @@ impl ReadView { &self, ids: Vec, ) -> impl Stream> { - // let ids = Box::new(ids.iter()); - // let messages: Vec<_> = self - // .on_chain - // .as_ref() - // .storage::() - // .get_multi(Box::new(ids)) - // .map(|res| { - // res.and_then(|opt| opt.ok_or(not_found!(Messages)).map(Cow::into_owned)) - // }) - // .collect(); - let messages: Vec<_> = self .on_chain .message_batch(ids.iter().into_boxed()) .collect(); - //// TODO: Use multiget when it's implemented. - //// https://github.com/FuelLabs/fuel-core/issues/2344 - // let messages = ids.into_iter().map(|id| self.message(&id)); - //// Give a chance to other tasks to run. + // Give a chance for other tasks to run. tokio::task::yield_now().await; + futures::stream::iter(messages) } diff --git a/crates/storage/src/lib.rs b/crates/storage/src/lib.rs index 185785cd7b7..306b4ade192 100644 --- a/crates/storage/src/lib.rs +++ b/crates/storage/src/lib.rs @@ -177,10 +177,11 @@ pub trait StorageBatchMutate: StorageMutate { Type::Key: 'a; } -// TODO: Document -/// TODO +/// Allows getting batches of values from the storage, +/// which can be faster in certain implementatoins than +/// getting values one by one. pub trait StorageBatchInspect { - /// TODO + /// Get a batch of values associated with the provided keys. fn get_batch<'a>( &'a self, keys: BoxedIter<'a, &'a Type::Key>,