1

I need to iterate over the following double map inside an offchain worker:

enter image description here

How can I access this map outside the pallet assets? Can I use an RPC method to get all the values for that double map inside an offchain worker?

It should be done with fn iter_key_prefix() from the IterableStorageDoubleMap trait?

1 Answer 1

0

Are you still running into this issue?

I believe you can do something like this:

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
    fn offchain_worker(now: T::BlockNumber) {
        YourStorageMapHere::<T>::iter().for_each(|v| {
            // Do things with the iterated values `v` in here
        });
    }
}

Bear in mind the usual considerations when developing around offchain workers, for example, not trusting the offchain worker.

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.