Questions tagged [storagemap]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
14 views

Best way to clear() StorageMap, DoubleStorageMap, and StorageValue

I have seen this answer: What is the time complexity of StorageMap::clear()? But how possible is it that clear() or clear_prefix() doesn't actually clear all of the storage elements when using u32::...
Bob Linux's user avatar
  • 111
2 votes
1 answer
68 views

removing a StorageMap from a pallet

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 ...
Alin Dima's user avatar
2 votes
2 answers
43 views

Set max amount of entries that can be stored in StorageMap

I would like to know how I can set a threshold of 10 entries so that it's the maximum number of values that can be stored in a StorageMap structure. My struct is the following: #[pallet::storage] pub ...
nhussein11's user avatar
2 votes
0 answers
28 views

How to convert AccountId from [hexadecimal, SS58Check]?[Updated]

I have two 2 storage in the pallet : #[pallet::storage] #[pallet::getter(fn subscriber)] pub type Subscriber<T:Config> = StorageValue<_, BoundedVec<T::AccountId, T::...
Deepak Chaudhary's user avatar
0 votes
1 answer
13 views

Batch insert into StorageMap without iterations

Is there a way to do batch inset operation into a StorageMap without iteration or using a Vec[] type or best workarounds. and if its not whats the reason for not supporting this? For example there's a ...
Rehan's user avatar
  • 167
1 vote
1 answer
71 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
  • 13
0 votes
2 answers
47 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
44 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
28 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
56 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
  • 212
3 votes
1 answer
75 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
  • 2,031
0 votes
1 answer
42 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
19 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
  • 369
3 votes
2 answers
37 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
35 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
  • 543
4 votes
1 answer
81 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
  • 543
3 votes
1 answer
56 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
  • 543
2 votes
2 answers
65 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
  • 189
2 votes
1 answer
50 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
31 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 B's user avatar
3 votes
0 answers
61 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
96 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
87 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
221 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
1 vote
1 answer
127 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
  • 543
2 votes
1 answer
119 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