3

I'd like to set an upper limit on the size of a storage map. Is there a data structure that supports this check within its methods? Or has anyone defined their own wrapper data structure that performs these checks on each insertion?

2 Answers 2

3

If you want a hard limit, then you have to create a wrapper.
The MaxValues on StorageMap and CountedStorageMap are only a soft limit for PoV estimations.

I don't know of any implementations of this. Not sure what you are trying to do either.

2

There is a counted storage map: doc implementation

pub struct CountedStorageMap<
 Prefix,
 Hasher,
 Key, 
 Value, 
 QueryKind = OptionQuery,
 OnEmpty = GetDefault,
 MaxValues = GetDefault
>(/* private fields */);
2
  • As discussed in dms, insert and set don't perform any max count check. Not sure what the purpose of MaxValues is. Commented May 17, 2023 at 16:52
  • The MaxValues is to calculate an upper limit for the worst-case Proof size estimation. Commented May 18, 2023 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.