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

Optim ledger_db get_datastore_keys #3275

Closed
sydhds opened this issue Nov 29, 2022 · 2 comments
Closed

Optim ledger_db get_datastore_keys #3275

sydhds opened this issue Nov 29, 2022 · 2 comments
Assignees

Comments

@sydhds
Copy link
Contributor

sydhds commented Nov 29, 2022

get_datastore_keys() should return None if addr does not exist but for now it will return an empty BTreeSet.

So the get_keys in speculative_ledger.rs should do first an entry_exists() and then a get_datastore_keys() and it looks suboptimal because the balance (tested for entry_exists) and the datastore keys are consecutive in the ledger, but we fully independently look them up without hints (logarithmic search).

@Ben-PH
Copy link
Contributor

Ben-PH commented Jan 17, 2023

What I'm thinking at this point, is to provide an interface that allows you to do a batch-get of the data-base entries using this method.

I'm thinking something like this (except not so jankey. Perhaps with builder pattern, and perhaps encapsulate the types somehow)

    pub fn batch_get_sub_entries(&self, address: &Address, balance: bool, bytecode: bool, datastore: Option<Vec[u8]>) -> Option<(Option<Vec[u8]>, Option<Vec[u8]>, Option<Vec[u8]>)> 

This could allow for a refactor of entry_exists() to

  • when need to know if anything exists, just get something, and follow up with a is_some() further up the stack
  • when used in the context of what this issue is trying to address, can get what's needed, while leaning into the rocks-db optimisations available.

unless there is a way to make assumptions about storage, thus allowing us to get all three in a single get?

@Ben-PH
Copy link
Contributor

Ben-PH commented Jan 18, 2023

Continuing this discussion in #3437

@Ben-PH Ben-PH closed this as completed Jan 18, 2023
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

No branches or pull requests

2 participants