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

Share more logic between different DB implementations. #5005

Open
ruseinov opened this issue Nov 26, 2024 · 1 comment
Open

Share more logic between different DB implementations. #5005

ruseinov opened this issue Nov 26, 2024 · 1 comment

Comments

@ruseinov
Copy link
Contributor

Currently the implementations of Blockstore, PersistentStore and other interfaces are completely independent for MemoryDB and ParityDB. Which means that if we test e.g. GC on MemoryDB - it's not guaranteed to have the same behaviour on ParityDB.

Perhaps a different approach should be considered, where more of the DB logic is shared.

For example the persistent storage fallback:

    fn get(&self, k: &Cid) -> anyhow::Result<Option<Vec<u8>>> {
        Ok(self
            .blockchain_db
            .read()
            .get(&k.to_bytes())
            .cloned()
            .or(self
                .blockchain_persistent_db
                .read()
                .get(&k.to_bytes())
                .cloned()))
    }

Could be completely generic across multiple databases. One way to achieve that is introducing a forest-specific (or chainsafe-specific) trait that all the database in question would implement. Then the implementation for many of the other traits could be based on the exposed interface as opposed to being database-specific.

@ruseinov
Copy link
Contributor Author

Related to e.g. #4959

@ruseinov ruseinov mentioned this issue Nov 26, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

No branches or pull requests

1 participant