Skip to content

Commit

Permalink
feat: Allow for changing cached reads inside of BlockBuildingHelperFr…
Browse files Browse the repository at this point in the history
…omDB (#189)

#178 

- Added `update_cached_reads` method to the `BlockBuildingHelper` trait
- Implemented `update_cached_reads` for `BlockBuildingHelperFromDB`
- Updated `MockBlockBuildingHelper` to include an unimplemented
`update_cached_reads` method

## ✅ I have completed the following steps:

* [ ✅] Run `make lint`
* [✅ ] Run `make test`

---------

Signed-off-by: 7suyash7 <[email protected]>
  • Loading branch information
7suyash7 committed Sep 27, 2024
1 parent 73629a2 commit 10495ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ pub trait BlockBuildingHelper: Send + Sync {

/// BlockBuildingContext used for building.
fn building_context(&self) -> &BlockBuildingContext;

/// Updates the cached reads for the block state.
fn update_cached_reads(&mut self, cached_reads: CachedReads);
}

/// Implementation of BlockBuildingHelper based on a ProviderFactory<DB>
Expand Down Expand Up @@ -386,4 +389,8 @@ impl<DB: Database + Clone + 'static> BlockBuildingHelper for BlockBuildingHelper
fn box_clone(&self) -> Box<dyn BlockBuildingHelper> {
Box::new(self.clone())
}

fn update_cached_reads(&mut self, cached_reads: CachedReads) {
self.block_state = self.block_state.clone().with_cached_reads(cached_reads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@ impl BlockBuildingHelper for MockBlockBuildingHelper {
fn building_context(&self) -> &BlockBuildingContext {
&self.block_building_context
}

fn update_cached_reads(&mut self, _cached_reads: CachedReads) {
unimplemented!()
}
}

0 comments on commit 10495ea

Please sign in to comment.