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
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.
There is a counted storage map: doc implementation
pub struct CountedStorageMap<
Prefix,
Hasher,
Key,
Value,
QueryKind = OptionQuery,
OnEmpty = GetDefault,
MaxValues = GetDefault
>(/* private fields */);
-
As discussed in dms,
insert
andset
don't perform any max count check. Not sure what the purpose ofMaxValues
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