Skip to main content
14 votes

Is there a limit to the size of a map in Pallet storage?

There isn't a strict limit, however the more entries a map has, the more trie nodes need to be read/altered when accessing it, so overall the slower the I/O. It's logarithmic in complexity, so you can ...
Gav's user avatar
  • 2,681
11 votes
Accepted

Is there a limit to the size of a map in Pallet storage?

Storage size and density are both relevant concerns when it comes to the performance of your chain. There are limits and performance implications at many levels so I will break them down: Physical ...
Shawn Tabrizi's user avatar
  • 16.1k
7 votes
Accepted

How to limit the number of values by prefix in StorageDoubleMap?

You could also use a vector as a value to AccountId. #[pallet::storage] #[pallet::getter(fn addresses_owned)] /// Keeps track of address owners. pub(super) type AddressOwners<T: Config> = ...
Amir Boziev's user avatar
5 votes

How to limit the number of values by prefix in StorageDoubleMap?

Any solution to this problem, whether provided by FRAME or implemented manually, would require storing the number of items currently in the map in some other storage location, since you would never ...
Shawn Tabrizi's user avatar
  • 16.1k
4 votes

How to limit the number of values by prefix in StorageDoubleMap?

At the moment I think you would need to keep some other storage items to track the amount of entries per AccountId. However, I think being able to bound the number of entries per key in a double map ...
zekemostov's user avatar
4 votes
Accepted

Multiple remove_all calls in same block

This is expected behavior. At least for now. I opened the following pr to improve the docs around this: https://github.com/paritytech/substrate/pull/11182
bkchr's user avatar
  • 11.6k
4 votes
Accepted

Definition of storage map for stored items

It's not standard Rust syntax because it makes use of the #[pallet::storage] macro. Please have a look at the official documentation for the macro and the StorageMap type for more information. In ...
William Freudenberger's user avatar
3 votes
Accepted

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

Not random. The keys used in the merkle trie result from hashing with https://paritytech.github.io/substrate/master/frame_support/trait.StorageHasher.html. So the iteration order is deterministic (...
cheme's user avatar
  • 456
2 votes

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

If you want to iterate over something then it cannot change in the meantime. This applies to storage maps as well. Iterating over large StorageMaps in calls is not a good idea in general since it uses ...
Oliver Tale-Yazdi's user avatar
1 vote

query storage to front-end

Two things: it needs an .entries() first the await is missing let scores = await api.query.pallet_template.scoreBoard.entries(); scores.map(console.log);
Oliver Tale-Yazdi's user avatar
1 vote

How to store a bounded map inside `StorageValue`?

If i have understood your question correctly you are asking if you can store a BoundedBTreeMap inside a storage value and what is the complexity of iterating over values in the BTree or getting a ...
gatsey's user avatar
  • 183
1 vote

How to select n random keys from a `StorageMap`?

Maybe you need a StorageValue<Vec<(Index, AccountId)>>. let v = StorageValue::get(); let index = v[random % v.len()]; let account_id = v[i]; Or StorageMap<Index, AccountId> + ...
AurevoirXavier's user avatar
  • 10.7k
1 vote
Accepted

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

The main difference to me is if it returns a closure. When you just want to remove it: Foo::clear_prefix(); Note: these are pseudo code When you want to interact with the removed item: Foo::...
AurevoirXavier's user avatar
  • 10.7k
1 vote
Accepted

Runtime API to collect values in StorageMap

This should work. I added a comment above the line in the code to explain what happens there. impl pallet_submitter_runtime_api::SubmitterRuntimeApi<Block> for Runtime { fn ...
bkchr's user avatar
  • 11.6k

Only top scored, non community-wiki answers of a minimum length are eligible