From 5b3fade37acba8663e575b7fbb8327493d994f44 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Thu, 12 Sep 2024 09:47:33 +0100 Subject: [PATCH] implement 'read' for BlockDb so it can call 'scan_cached_blocks' --- zcash_client_sqlite/src/lib.rs | 37 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/zcash_client_sqlite/src/lib.rs b/zcash_client_sqlite/src/lib.rs index e32b71c4c0..d7c6d842d4 100644 --- a/zcash_client_sqlite/src/lib.rs +++ b/zcash_client_sqlite/src/lib.rs @@ -1652,6 +1652,7 @@ impl BlockSource for BlockDb { } } +#[async_trait::async_trait] impl BlockCache for BlockDb { fn get_tip_height<'life0, 'life1, 'async_trait, WalletErrT>( &'life0 self, @@ -1675,27 +1676,21 @@ impl BlockCache for BlockDb { todo!() } - fn read<'life0, 'life1, 'async_trait, WalletErrT>( - &'life0 self, - _range: &'life1 ScanRange, - ) -> core::pin::Pin< - Box< - dyn core::future::Future< - Output = Result< - Vec, - data_api::chain::error::Error, - >, - > + core::marker::Send - + 'async_trait, - >, - > - where - WalletErrT: 'async_trait, - 'life0: 'async_trait, - 'life1: 'async_trait, - Self: 'async_trait, - { - todo!() + async fn read( + &self, + range: &ScanRange, + ) -> Result, data_api::chain::error::Error> { + let mut compact_blocks = vec![]; + self.with_blocks( + Some(range.block_range().start), + Some(range.len()), + |block| { + compact_blocks.push(block); + Ok(()) + }, + ) + .await?; + Ok(compact_blocks) } fn insert<'life0, 'async_trait, WalletErrT>(