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

lexi: add new database package #3033

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

buck54321
Copy link
Member

Add the Lexi DB package, which wraps badger DB to provide a simplified API, to capture the sometimes tedious mechanics that we've repeated in various places, and to add utilities for indexing data for quick retrieval of filtered data.

This change is just the addition of the package. I will demonstrate it's use in tatanka separately.

I'll add some more testing, but feel free to review as is.

See this diff for an example of how it would replace the tx DB for Ethereum.

Add the Lexi DB package, which wraps badger DB to provide a simplified
API, to capture the sometimes tedious mechanics that we've repeated
in various places, and to add utilities for indexing data for quick
retrieval of filtered data.

This change is just the addition of the package. I will demonstrate
it's use in tatanka separately, and also show how this can replace
in our client/asset tx DB implementations.
Comment on lines +25 to +29
bLen := 1 + len(d.v) + wire.VarIntSerializeSize(uint64(len(d.v))) + wire.VarIntSerializeSize(uint64(len(d.indexes)))
for _, ib := range d.indexes {
bLen += len(ib) + wire.VarIntSerializeSize(uint64(len(ib)))
}
b := bytes.NewBuffer(make([]byte, 0, bLen))
Copy link
Member Author

@buck54321 buck54321 Oct 21, 2024

Choose a reason for hiding this comment

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

Oops. I forgot to doc this encoding stuff. It's pretty much like BuildyBytes, but I'm pre-allocating the buffer and allowing any blob size. And I'm leveraging wire for the var int stuff.

I guess its a lot of work just to pre-allocate the buffer though. derp.

Copy link
Contributor

Choose a reason for hiding this comment

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

When reading the doc I noticed this:

// MarshalJSON satisfies the json.Unmarshaler interface, returns a quoted copy

"...satisfies the json.Unmarshaler interface..."

I think it is the json.Marshaller interface. I could be wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

Tests all PASS on my machine.

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.

3 participants