2

I am looking to completely remove a StorageMap from the inclusion runtime module of the polkadot relay chain. I am writing a migration for it and I'm wondering whether it's enough to call clear on the map: https://paritytech.github.io/polkadot-sdk/master/frame_support/storage/types/struct.StorageMap.html#method.clear

Will clear delete all the stored data (including any metadata related to the map), or just the elements?

Looking at the implementation, it ends up calling clear_prefix, which should delete all info from the storage trie with the prefix, so I'm assuming this is the way to go.

1 Answer 1

3

Yes, this will remove all the entries. The StorageMap itself doesn't has any metadata that is stored in the state. Before deleting the map, you should check the number of elements in it. Deleting millions of key/value pairs would take some time ;) In this case a multi-block migration would probably be better.

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.