zcash / librustzcash

Rust-language assets for Zcash
Other
324 stars 243 forks source link

zcash_client_backend: Introduce (initially internal) "sync API" between the scanning and wallet parts of `scan_cached_blocks` #1368

Open str4d opened 2 months ago

str4d commented 2 months ago

Currently scan_cached_blocks takes a BlockSource and a WalletWrite, and combines their information to scan a given range of blocks. It would be useful to clearly denote the dataflows here, as we have the following conceptual relationship that we would like to embody in the zcashd wallet replacement:

sequenceDiagram
    Wallet->>Scanner: Viewing keys
    Wallet->>Scanner: Nullifiers, scan range
    Scanner->>Block Source: Request blocks
    Block Source-->>+Scanner: Blocks
    Scanner-->>-Wallet: Scanned notes

We should ensure that the individual logic necessary for these three components is accessible from zcash_client_backend, by refactoring the internals of scan_cached_blocks to leverage them in this way. This might coincide with the exposition of the BatchRunners type, or it might just mean exposing a wrapper around it that a future Scanner could use.