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

merkledb -- encode lengths as uvarints #2039

Merged
merged 15 commits into from
Sep 19, 2023
Merged

merkledb -- encode lengths as uvarints #2039

merged 15 commits into from
Sep 19, 2023

Conversation

danlaine
Copy link

Why this should be merged

These lengths can never be negative.

How this works

Varint --> Uvarint

How this was tested

Existing UT

@danlaine danlaine self-assigned this Sep 19, 2023
@danlaine danlaine changed the title merkledb -- encode lengths as uint64 merkledb -- encode lengths as uvarints Sep 19, 2023
@@ -221,18 +220,15 @@ func (*codecImpl) decodeBool(src *bytes.Reader) (bool, error) {
}
}

func (c *codecImpl) encodeInt(dst *bytes.Buffer, value int) {
Copy link
Author

Choose a reason for hiding this comment

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

We only encode non-negative ints so this was replaced with encodeUint64


func (*codecImpl) decodeInt(src *bytes.Reader) (int, error) {
// decodeUint decodes a uvarint from [src] and returns it as an int.
func (*codecImpl) decodeUint(src *bytes.Reader) (int, error) {
Copy link
Author

Choose a reason for hiding this comment

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

Arguably this should return a uint but a bunch of places where we use this, we want it as an int, so idk

Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to just update all of those variables to be uints instead?

c.encodeInt64(dst, int64(value))
}

func (*codecImpl) decodeInt(src *bytes.Reader) (int, error) {
Copy link
Author

Choose a reason for hiding this comment

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

Changed to decodeUint since we always read uint64s

@danlaine danlaine marked this pull request as draft September 19, 2023 15:48
@danlaine danlaine marked this pull request as ready for review September 19, 2023 17:28
@danlaine danlaine merged commit bd83641 into dev Sep 19, 2023
16 checks passed
@danlaine danlaine deleted the merkledb-codec-unit branch September 19, 2023 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants