Conversation
srml/metadata/src/lib.rs
Outdated
| #[cfg_attr(feature = "std", derive(Decode, Debug, Serialize))] | ||
| pub enum StorageFunctionType { | ||
| Plain(DecodeDifferentStr), | ||
| List(DecodeDifferentStr), |
There was a problem hiding this comment.
please put this to the end to improve backward compatibility
|
|
||
| /// Push a new item to the list. | ||
| fn push(item: &T); | ||
|
|
There was a problem hiding this comment.
no pop method? how do I delete the last item?
|
I thought we won't bring back storage list because of the performance issues. See here #772 |
|
We do have |
|
To clarify on my "more efficient" comment, after discussing that with @bkchr . However:
|
|
I see some use cases of storage list. Every data structure have its trade offs. I think Substrate should offer (secure and safe) options and guidances to help developers to make right decisions. |
|
You will need to iterate events at the end of each block and that will create a lot of database accesses. |
|
Why do I need to iterate events? To conver to Vec for compatibility reason? I believe polkadotjs is able to somehow detects the format and handle both cases just like metadata versions |
|
Yeah, good point^^ |
It does not necessarily need any database access. For something like |
|
Yeah I know that we don't always access the real database. Nevertheless, we still need to have 1 lookups + 2 writes for storing one event. (events are also part of the storage root, as they stay for the client to inspect them) |
|
Indeed. Events are not free - the stick around until the next block and therefore bloat the trie and increase hashing required and then you'll need to iterate over all of the last block's events to delete them, increasing I/O. |
|
Events bottleneck is also already fixed in master. So how do we continue with this one? Close? |
Add back storage list support in
decl_storagemacro. Can fix issues like #2228.A QoL function
StorageList::pushis also added.