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

Separate nodes and values #1770

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Conversation

Harrm
Copy link
Contributor

@Harrm Harrm commented Aug 28, 2023

Referenced issues

Description of the Change

Benefits

Possible Drawbacks

Usage Examples or Tests

Alternate Designs

Comment on lines +21 to +32
class TrieNodeStorageBackend : public BufferStorage {
public:
~TrieStorageBackend() override = default;
~TrieNodeStorageBackend() override = default;
};

/**
* Adapter for the trie value storage that allows to hide keyspace separation
* along with root hash storing logic from the trie db component
*/
class TrieValueStorageBackend : public BufferStorage {
public:
~TrieValueStorageBackend() override = default;
Copy link
Contributor

@turuslan turuslan Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove TrieNodeStorageBackend and TrieValueStorageBackend.

Use BufferStorage directly (or new simple interface TrieDb { get(Hash): Opt<Cow>; put(Hash, Cow); }, maybe get and put can accept bool for value/node).

If you want strong type for injection, then
don't inherit interface (because you can't use parent interface implementation struct IDb{}; struct Db:IDb{}; struct IDb2:IDb{}; IDb2 idb2 = new Db{};)
but wrapper struct (struct TrieDbNode { IDb _; }; struct TrieDbValue { IDb _; }; or struct TrieDb { IDb node, value; }),
or don't inject

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

@turuslan turuslan mentioned this pull request Nov 24, 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

Successfully merging this pull request may close these issues.

None yet

2 participants