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

Add Compact{16,32,64,128,256} #219

Merged
merged 3 commits into from
Oct 8, 2018
Merged

Add Compact{16,32,64,128,256} #219

merged 3 commits into from
Oct 8, 2018

Conversation

jacogr
Copy link
Member

@jacogr jacogr commented Oct 6, 2018

}

fromU8a (input: Uint8Array): Bytes {
const [offset, length] = Compact.decode(input);
const [offset, length] = Compact.decodeU8a(input, DEFAULT_LENGTH_BITS);
Copy link
Contributor

@amaury1093 amaury1093 Oct 8, 2018

Choose a reason for hiding this comment

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

Instead of adding DEFAULT_LENGTH_BITS as 2nd arg everywhere, you could add a default value for this 2nd arg in the function definition? (you'll probably make codeclimate happy too)

Copy link
Member Author

Choose a reason for hiding this comment

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

It was that way originally, but it creates issues and bugs that look correct.

i.e. for numbers, you want the default to probaly be 64, but for lengths it needs to be 32. So made it explicit everywhere. (The issue is not an issue yet, but will be - all numbers will be compact encoded in the system, so want to make sure we pass the param through and not just forget about it.)

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

OK!

@amaury1093 amaury1093 merged commit dc88797 into master Oct 8, 2018
@amaury1093 amaury1093 deleted the jg-compact branch October 8, 2018 13:47
@polkadot-js-bot
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jun 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Compact{8,16,32,64,128,256} coders
3 participants