fix: uints are ok#20
Merged
Merged
Conversation
frrist
approved these changes
May 15, 2026
frrist
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nowhere on the IPLD docs/specs is there any mention of uint being supported.
The only discussion I can find of this is here and here.
It is NOT supported in IPLD.
HOWEVER
CBOR does not support
uints either! It supports positive and negative ints. Thecbor-gentool just outputs the correct header depending on the type and value. i.e. forintit outputs either "unsigned int header" or "negative int header" and when it has auint, it only outputs "unsigned int header" (since it cannot be negative).So by using
uints, we're still outputting dag-cbor compliant encoding data.Where it gets interesting is when you deserialize. If you're trying to deserialize into a
uint, thencbor-genactually gives you more type safety since it'll try to read a "unsigned int header" and will fail if it sees a "negative int header", which saves us having to do a bunch of < 0 checks in code.i.e. we should just use
uintwhere it's appropriate and stop worrying.