librustzcash icon indicating copy to clipboard operation
librustzcash copied to clipboard

Implement BlockCache trait for FsBlockDb

Open Oscar-Pepper opened this issue 1 year ago • 3 comments

  • Implements Sync trait for BlockDb and FsBlockDb (trait bound for BlockCache trait)
  • Implements BlockCache for FsBlockDb
  • Scan_cached_blocks takes a BlockCache instead of BlockSource to solve issues with thread safety with callback and also update the sync engine to use only BlockCache trait methods
  • Changes fns and tests to async as a result of implementing Sync trait for BlockDb and FsBlockDb
  • implements BlockCache::read for BlockDb, neccessary for calling scan_cached_blocks

Oscar-Pepper avatar Sep 11 '24 09:09 Oscar-Pepper

Rebased on main to fix major merge conflicts after the test framework was moved out of zcash_client_sqlite.

I'm going to perform more rebases on this to clean up the commit history and break apart the larger changes as best I can, to make the PR easier to review and potentially break out smaller pieces of it into separate PRs.

str4d avatar Oct 25 '24 06:10 str4d

Rebased on main to fix more merge conflicts.

str4d avatar Oct 26 '24 02:10 str4d

Force-pushed to refactor the commits without any changes. In particular, I've pulled most of the async test changes out into a final commit, because I do not want the test framework to be async (at least at this stage), and we can instead use futures::executor::block_on wherever the test framework needs to use async functions (I haven't implemented this change yet but will do so).

I also plan to rebase this PR again once #1595 merges, to move away from the async-trait crate which I think will significantly simplify this PR.

str4d avatar Oct 26 '24 06:10 str4d

Rebased on main to move away from the async-trait crate. I also did some more reworking of the commits to split them into logical changes. I almost have the test framework async-ness confined to the last commit; there is just one test in zcash_client_sqlite of FsBlockDb that needs adjusting.

The main next thing I want to figure out is whether the current state of the first commit can be paired down even further. BlockSource is made async in this PR, and I want to figure out whether that is necessary or not for the stated PR goal of implementing BlockCache for FsBlockDb.

str4d avatar Oct 28 '24 22:10 str4d

Force-pushed to remove the dependency of BlockSource on data_api::chain::Error, and thus remove the similar complexity that this PR added to BlockCache.

str4d avatar Oct 29 '24 02:10 str4d