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?
If you want a hard limit, then you have to create a wrapper.
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,
setdon't perform any max count check. Not sure what the purpose of
MaxValuesis. May 17 at 16:52
MaxValuesis to calculate an upper limit for the worst-case Proof size estimation. May 18 at 20:06