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

Implement BoundedEncodedLength trait and implementations on primitives #267

Closed
wants to merge 9 commits into from

Conversation

coriolinus
Copy link
Contributor

No description provided.

@coriolinus coriolinus self-assigned this May 3, 2021
@coriolinus coriolinus marked this pull request as ready for review May 3, 2021 13:59
/// can be implemented accurately. Other containers, such as `StorageMap`, do not have enforced size
/// limits. For those containers, it is necessary to make a documented assumption about the maximum
/// usage, and compute the max encoded length based on that assumption.
pub trait BoundedEncodedLen: Encode {
Copy link
Member

Choose a reason for hiding this comment

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

I still don't see why this should be implemented in scale. This is Substrate specific and not SCALE specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The short answer is that Encode::size_hint is toothless: it's a 'best-effort' thing with a useless default implementation. Still, we do have the need sometimes for a more realistic size hint, and that need is generalizable to all of SCALE, not just Substrate.

Copy link
Member

Choose a reason for hiding this comment

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

This is also "toothless" as what is the maximum size of a vec?

As already said in element, I don't see this in SCALE.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not implemented for Vec 😁. I'll move this work to the substrate repo instead though.

@coriolinus
Copy link
Contributor Author

Transferred to paritytech/substrate#8720.

@coriolinus coriolinus closed this May 4, 2021
@coriolinus coriolinus deleted the prgn-bounded-encoded-length branch May 4, 2021 08:58
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