Questions tagged [storagemap]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
39 views

How to get typed keys when querying a storage map via subxt

The example here https://github.com/paritytech/subxt/blob/master/subxt/examples/storage_iterating.rs use subxt::{OnlineClient, PolkadotConfig}; #[subxt::subxt(runtime_metadata_path = "../...
Damian's user avatar
  • 3
0 votes
2 answers
37 views

Trying to store StorageMap<_, Twox64Concat, u128, (SomeStruct1, SomeStruct2<SomeType>), ValueQuery>

Getting the error: the trait MaxEncodedLen is not implemented for SomeStruct If I add MaxEncodedLen to the #[derive()] list it changes to this: error[E0599]: no function or associated item named ...
Aaron Ely's user avatar
1 vote
2 answers
32 views

How many ways are there to get all items stored in custom pallet

I would like to know what are the ways and how we can retrieve the all items stored in a custom pallet I was having data structured in this way #[derive( Clone, Encode, Decode, Eq, PartialEq, ...
Mojo's user avatar
  • 95
2 votes
1 answer
27 views

Data structure to choose for ordered items?

Can someone help me understand the difference b/w using a Vec (BoundedVec) instead of a StorageMap for storing ordered items? Basically inside a vector, the index would be an indicator of order ...
Purple_Turtle's user avatar
2 votes
1 answer
49 views

Returning dynamic default values from StorageMap

I'm working with a StorageMap and want to return a dynamic default value based on the queried key when the key isn't found. Here's my attempt: #[pallet::storage] #[pallet::getter(fn asset)] pub(super) ...
magecnion's user avatar
  • 148
3 votes
1 answer
47 views

How we can iterate over all items in a storage map?

I have a storage in pallet pub type Users<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, User>; I need to iterate over all the storage map to check a field data inside the ...
Pankaj's user avatar
  • 1,896
0 votes
1 answer
34 views

Subscribe to storage map Entries?

On our substrate node using a storage double map. We are trying to subscribe to an entries query. something like const unsub = await api.query.system.balances.entries(ADDR, (res) => { console....
donkeydonkey's user avatar
3 votes
1 answer
17 views

Query chain for types in a storagemap

I want to get the meta function description of pallets storage maps. Returning an output like this: { Twox64Concat, [u8; 16], u32 } = query.storagemap(pallet: "template", storagemap: "...
flipchan's user avatar
  • 319
3 votes
2 answers
28 views

`BoundedBTreeMap` equivalent for `StorageMap`?

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 ...
Daniel Savu's user avatar
3 votes
2 answers
34 views

How to check if a `StorageMap` changed after the last access?

I am currently trying to iterate over a storage map over multiple blocks. For this I need to ensure that the StorageMap was not modified. My plan is to derive a hash from the current StorageMap and ...
Chralt's user avatar
  • 503
4 votes
1 answer
66 views

How to iterate a large `StorageMap` over multiple extrinsic calls?

Hey valuable Substrate community, I am running into the problem that I need to iterate over an unbounded StorageMap. So I need an IterationLimit and use an extrinsic which gets called multiple times. ...
Chralt's user avatar
  • 503
3 votes
1 answer
53 views

What does `no particular order` mean for storage iterations?

I am always curious what the documentation for the storage means when I see the following. Enumerate all elements in the map in no particular order. https://paritytech.github.io/substrate/master/...
Chralt's user avatar
  • 503
2 votes
2 answers
52 views

Number of and writes of StorageMap drain

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 (n, n)?
0x5hmoo's user avatar
  • 167
2 votes
1 answer
39 views

Is migration required after adding an extra storage map to a pallet

From my understanding how the runtime store its state adding an extra storage variable like pub Verified (get fn is_verified): map hasher(blake2_128_concat) us64 => (); to a pallet that already ...
mr_bovo's user avatar
  • 171
2 votes
2 answers
29 views

How to change one of the two `StorageDoubleMap` keys?

Say I have a StorageDoubleMap like this pub type Users<T: Config> = StorageDoubleMap<_, Twox64Concat, Vec<u8>, Twox64Concat, Compact<u64>, Person<T::AccountId>,>; where ...
Alessandro Baffa's user avatar
3 votes
0 answers
55 views

How does one figure what the total db reads & writes are for a clear_prefix call?

We need to perform a clear_prefix on a StorageDoubleMap every N blocks in on_initialize(), and we want to make sure the WeightInfo call properly accounts for read/writes. Should we simply pass unique ...
Shannon Wells's user avatar
2 votes
1 answer
77 views

storage double map key deletion

Consider a substrate double map pub Foo get(fn category_by_moderator): double_map hasher(blake2_128_concat) T::K1, hasher(blake2_128_concat) T::K2 => T::V; Suppose I want to delete all ...
mr_bovo's user avatar
  • 171
1 vote
1 answer
83 views

Off-chain local storage map?

I have an off-chain worker that needs to write a HashMap<u64,Vec<u64>> to local storage. I can see how to write a single value using StorageValueRef and how I could possibly store a ...
Robert La Ferla's user avatar
0 votes
3 answers
187 views

How to mutate a `StorageDoubleMap` value?

I have StorageDoubleMap for ERC1155 balances u32 -> AccountId -> u32; How can I mutate this map like balances[1][SomeAccountId] -= 4?
Nikita Chernega's user avatar
1 vote
0 answers
41 views

How to encode data off-chain and push to child storage trie on Substrate?

I am creating the reward pool concept that allows users to claim reward pool. For scalability, we used Child Storage trie for different pool as trie_index. Each trie_index has [wallet, ...
jpcoder's user avatar
  • 98
0 votes
1 answer
102 views

When to use StorageDoubleMap `clear_prefix` vs `drain_prefix`?

Hey Substrate community, there are two different methods to remove multiple items for one specific first key from a StorageDoubleMap. There is clear_prefix and drain_prefix. clear_prefix provides ...
Chralt's user avatar
  • 503
2 votes
1 answer
95 views

What is the time complexity of StorageMap::clear()?

It appears in substrate this is O(n), but want to confirm since I believe hashbrown just wipes control bytes, which appears O(1). Side note: The problem I'm trying to solve is tracking a number of ...
Jake Hemmerle's user avatar