I was wondering about the number of reads and writes when draining a StorageMap which consists of
n items. Is the answer
(n, 1) or
I'm not professional on this.
But these are what I found.
next_key cost 1 read.
kill cost 1 write.
kill interacts with the storage overlay. I'm not sure if there is any optimization.
(n, n) You have to iterate all the storage and perform and update on each element (In your case removing the element).
Not sure if you are implementing it yourself, but you have a function drain() that does that.
let mut drained_keys = MyStorageMap::iter_keys().drain().collect::<Vec<_>>();