-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add swap and decode_len to DoubleMap
#3749
Conversation
|
It looks like @rockbmb signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
|
Still missing some tests, but the basic idea is there. |
srml/support/src/storage/mod.rs
Outdated
|
|
||
| /// Read the length of the value in a fast way, without decoding the entire value. | ||
| /// | ||
| /// `T` is required to implement `Codec::DecodeLength`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// `T` is required to implement `Codec::DecodeLength`. | |
| /// `V` is required to implement `Codec::DecodeLength`. |
Indeed, and thanks for the PR! 👍 |
|
yes great, you can add some basic test in |
|
Still need to figure out what structures need to be present for tests, WIP. |
bkchr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general, but requires some fixing to the tests and some other nitpicks.
srml/support/src/storage/mod.rs
Outdated
| KArg2: EncodeLike<K2>; | ||
|
|
||
| /// Swap the values of two key-pairs. | ||
| fn swap<KArg1, KArg2>(key11: KArg1, key12: KArg2, key21: KArg1, key22: KArg2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see 4 generic parameters here. Otherwise we force the user to have 2 times the same type. That is not something we wanted to achieve with EncodeLike.
srml/support/src/lib.rs
Outdated
| DataDM::insert(0, 3, 2); | ||
| DataDM::insert(0, 4, 3); | ||
|
|
||
| let collect = || DataDM::enumerate().collect::<Vec<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have enumerate() for double maps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does DataDM have available? I see that it's generated by a decl_storage! macro, a little hard to know what it actually is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decl_storage doc is here
so it implements StorageDoubleMap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I see - so we can't iterate over all (key1, key2, value) triplets.
| assert_eq!(OptionLinkedMapVec::decode_len(0), Ok(0)); | ||
|
|
||
| // Double map | ||
| assert_eq!(DoubleMapVec::get(0), vec![]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get() takes two parameters.
|
@rockbmb any update? |
|
@bkchr I'll circle back to this, handling other things at the moment. |
|
@rockbmb if you want to I can finish it |
|
@thiolliere thanks, I appreciate it but it's not that much work so I'll take care of it. If there's something I do not understand, I'll make sure to ping. |
|
Any update? |
|
@bkchr could you reply to #3749 (comment) please? |
|
any update here? |
|
If it's urgent to have this merged, I don't mind if it's taken over. |
|
It's more like that we want to merge it :) |
@thiolliere maybe it's worth you finishing it... |
Closes #3741.
cc @thiolliere