1

I have a StorageMap named PublicKeyToMsaId which has around 300K inserted items and I want to iterate on all of those keys-values in offchain-worker to create a reverse map in offchain storage.

To iterate I'm going to use PublicKeyToMsaId::iter() but by looking into the docs for iterator I can see the following

if you alter the map while doing this, you'll get undefined results.

Since I know that offchain-worker is running in a different thread, is it possible that when I'm iterating the map, an imported extrinsic might change some value on the map and the iterator on offchain-worker might end up in an undefined state?

1 Answer 1

0

So based on a number of experiments I was not able to reproduce any undefined behavior.

When iterating a storage map from offchain worker with a lot of items, any change to the StorageMap from extrinsics does not seems to have any effect on the iteration. Meaning that if any new item gets added or removed while iterating on the items in the map it would not show up in the iteration.

This is totally based on a number of experiments and it might not be 100% correct.

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.