Uh oh!
There was an error while loading. Please reload this page.
Add StorageList support in decl_storage - #2261
Conversation
| #[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?
bkchr
commented
Apr 12, 2019
I thought we won't bring back storage list because of the performance issues. See here #772 |
tomusdrw
commented
Apr 12, 2019
We do have |
To clarify on my "more efficient" comment, after discussing that with @bkchr . However:
|
xlc
commented
Apr 12, 2019
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. |
bkchr
commented
Apr 12, 2019
You will need to iterate events at the end of each block and that will create a lot of database accesses. |
xlc
commented
Apr 12, 2019
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 |
bkchr
commented
Apr 12, 2019
Yeah, good point^^ |
sorpaas
commented
Apr 13, 2019
It does not necessarily need any database access. For something like |
bkchr
commented
Apr 13, 2019
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) |
gavofyork
commented
Apr 19, 2019
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. |
bkchr
commented
Apr 19, 2019
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.