Skip to content

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
@coriolinus coriolinus requested review from gui1117 and shawntabrizi May 3, 2021 14:00
/// 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.

4 participants