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 dont know of any implementations of this. Not sure what you are trying to do either.
There is a counted storage map: https://github.com/paritytech/substrate/blob/6507a79b2baf7e4cc6f5868aa490dfe275144f9a/frame/support/src/storage/types/counted_map.rs#L38-L50
-
As discussed in dms,
insert
andset
don't perform any max count check. Not sure what the purpose ofMaxValues
is. May 17 at 16:52 -
The
MaxValues
is to calculate an upper limit for the worst-case Proof size estimation. May 18 at 20:06