Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing DeltaReader #7

Merged
merged 32 commits into from
Jun 4, 2024
Merged

Conversation

citizen-stig
Copy link
Member

@citizen-stig citizen-stig commented May 14, 2024

This PR adds a DeltaReader, that will be used by new storage manager.

DeltaReader resembles combination of CacheDb and CacheContainer

It has public API that can be used by StateDb, AccessoryDb and LedgerDb the almost same way as CacheDb (excluding writes, which is usage is in process of being removed from SDK).

And it also manages ordering of keys and iteration for snapshots and database. It doesn't have any implicit link to StorageManager. It explicitly gets list of snapshots and DB and it uses it to provide correct data.

Current code has some duplication with existing CacheDb and CacheContainer. This is intentional. After SDK migrates to new StorageManager, old Cache* related structs will be removed.

Here is a list of all public methods of DeltaReader and where they have been copied (*means with significant modifications). new is ignored as it is obvious constructor.

  • get : CacheDb::read + CacheDb::read_async. Now it does not lock, as it just iterate over Vec
  • get_largest: CacheDb::get_largest. But simplified as it doesn't have to join "local_cache" into picture
  • get_prev: CacheDb::get_prev. Same as get_largest
  • get_n_from_first_match: CacheDb::get_n_from_first_match
  • collect_in_range: CacheDb::collect_in_range

All iteration related logic is taken mainly from CacheContainer

@citizen-stig citizen-stig self-assigned this May 14, 2024
@citizen-stig citizen-stig force-pushed the nikolai/delta-db-introduction branch from cc769ae to 9ed4dc0 Compare May 30, 2024 11:15
@citizen-stig citizen-stig marked this pull request as ready for review May 31, 2024 14:42
@citizen-stig citizen-stig requested a review from neysofu May 31, 2024 14:47
@citizen-stig citizen-stig changed the title WIP: DeltaReader introduction Introducing DeltaReader May 31, 2024
src/cache/delta_reader.rs Outdated Show resolved Hide resolved
@citizen-stig citizen-stig merged commit 6e8be84 into main Jun 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants