-
Notifications
You must be signed in to change notification settings - Fork 95
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
Conversation
/// 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 { |
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.
I still don't see why this should be implemented in scale. This is Substrate specific and not SCALE specific.
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.
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.
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.
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.
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.
Not implemented for Vec
😁. I'll move this work to the substrate repo instead though.
Transferred to paritytech/substrate#8720. |
No description provided.