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

Ergonomics request: encapsulate the Cache in CacheDB<DB> to allow it to be used independently #1870

Open
prestwich opened this issue Nov 27, 2024 · 2 comments
Labels
good first issue Good for newcomers

Comments

@prestwich
Copy link
Contributor

It's often useful during simulation to separate cached updates from the underlying DB, so that they can (e.g.) be absorbed into a higher-level cache.

Requested refactor would look something like this:

pub struct Cache {
    pub accounts: HashMap<Address, DbAccount>,
    pub contracts: HashMap<B256, Bytecode>,
    pub logs: Vec<Log>,
    pub block_hashes: HashMap<U256, B256>,
}

pub struct CacheDB<ExtDB> {
    cache: Cache,
    db: ExtDb
}
@rakita
Copy link
Member

rakita commented Nov 29, 2024

This makes sense

@prestwich
Copy link
Contributor Author

I can prep a PR if it wouldn't interfere with any ongoing refactor work

@rakita rakita added the good first issue Good for newcomers label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants