-
Notifications
You must be signed in to change notification settings - Fork 2.7k
state_machine no_std witness externalities #6934
Changes from 22 commits
ea03567
c0e25ae
2cb6378
b0e04a4
a9aa27c
2747339
cac2280
11305d1
4f05206
d4ce6dd
147ef68
d067b0c
0e6b642
4c454cc
d32e3fd
753a8d7
2d63cf7
1fadc14
9b3146d
bdbaefc
d1b10c8
14e40b6
e459698
bef5997
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,8 +140,15 @@ fn prepare_extrinsics_input_inner<'a, B, H, Number>( | |
| Number: BlockNumber, | ||
| { | ||
| changes | ||
| .filter(|( _, v)| v.extrinsics().next().is_some()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change this code?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did modify the 'extrinsics' prototype to stop returning an iterator (before it was fusing iterator with itertools unique but I am do not like the implementation a lot (internal hashmap), so I simply return a btreeset instead, changing the code here calling 'extrinsics' multiple times, so avoid fusing the iterator multiple time).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you change this to a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well it avoid a tab, will change (easier to review, even if I like it better without the filter map, I am really waiting for rustc "Tracking issue for methods converting
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I remember, 'extrinsics' function is not a getter, it have an associated cost, that is the main reason (even if optimized by the compilator, this way of putting it makes it clear that we don't want to call the function multiple times, but I can write it with combinator too).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the problem. However the old implementation was also an |
||
| .try_fold(BTreeMap::new(), |mut map: BTreeMap<&[u8], (ExtrinsicIndex<Number>, Vec<u32>)>, (k, v)| { | ||
| .filter_map(|(k, v)| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks much better! |
||
| let extrinsics = v.extrinsics(); | ||
| if !extrinsics.is_empty() { | ||
| Some((k, extrinsics)) | ||
| } else { | ||
| None | ||
| } | ||
| }) | ||
| .try_fold(BTreeMap::new(), |mut map: BTreeMap<&[u8], (ExtrinsicIndex<Number>, Vec<u32>)>, (k, extrinsics)| { | ||
| match map.entry(k) { | ||
| Entry::Vacant(entry) => { | ||
| // ignore temporary values (values that have null value at the end of operation | ||
|
|
@@ -161,7 +168,7 @@ fn prepare_extrinsics_input_inner<'a, B, H, Number>( | |
| } | ||
| }; | ||
|
|
||
| let extrinsics = v.extrinsics().cloned().collect(); | ||
| let extrinsics = extrinsics.into_iter().collect(); | ||
| entry.insert((ExtrinsicIndex { | ||
| block: block.clone(), | ||
| key: k.to_vec(), | ||
|
|
@@ -170,11 +177,11 @@ fn prepare_extrinsics_input_inner<'a, B, H, Number>( | |
| Entry::Occupied(mut entry) => { | ||
| // we do not need to check for temporary values here, because entry is Occupied | ||
| // AND we are checking it before insertion | ||
| let extrinsics = &mut entry.get_mut().1; | ||
| extrinsics.extend( | ||
| v.extrinsics().cloned() | ||
| let entry_extrinsics = &mut entry.get_mut().1; | ||
| entry_extrinsics.extend( | ||
| extrinsics.into_iter() | ||
| ); | ||
| extrinsics.sort(); | ||
| entry_extrinsics.sort(); | ||
| }, | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.