-
Notifications
You must be signed in to change notification settings - Fork 674
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
Conversation
merkledb
-- encode lengths as uint64merkledb
-- encode lengths as uvarints
@@ -221,18 +220,15 @@ func (*codecImpl) decodeBool(src *bytes.Reader) (bool, error) { | |||
} | |||
} | |||
|
|||
func (c *codecImpl) encodeInt(dst *bytes.Buffer, value int) { |
There was a problem hiding this comment.
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
x/merkledb/codec.go
Outdated
|
||
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
… into merkledb-codec-unit
Why this should be merged
These lengths can never be negative.
How this works
Varint
-->Uvarint
How this was tested
Existing UT