This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move child changeset creation to constructor
- Loading branch information
Showing
2 changed files
with
31 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,19 +245,16 @@ impl OverlayedChanges { | |
let size_write = val.as_ref().map(|x| x.len() as u64).unwrap_or(0); | ||
self.stats.tally_write_overlay(size_write); | ||
let storage_key = child_info.storage_key().to_vec(); | ||
let tx_depth = self.transaction_depth(); | ||
let num_client_tx = self.top.num_client_transactions(); | ||
let exec_mode = self.top.execution_mode(); | ||
let (overlay, info) = self.children.entry(storage_key) | ||
.or_insert_with(|| ( | ||
// This changeset might be created when there are already open transactions. | ||
// We need to catch up here so it is at the same transaction depth. | ||
OverlayedChangeSet::new(tx_depth, num_client_tx, exec_mode), | ||
let changeset = self.top.spawn_child(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
athei
Author
Member
|
||
let (changeset, info) = self.children.entry(storage_key).or_insert_with(|| | ||
( | ||
changeset, | ||
child_info.to_owned() | ||
)); | ||
) | ||
); | ||
let updatable = info.try_update(child_info); | ||
debug_assert!(updatable); | ||
overlay.set(key, val, extrinsic_index); | ||
changeset.set(key, val, extrinsic_index); | ||
} | ||
|
||
/// Clear child storage of given storage key. | ||
|
@@ -268,9 +265,14 @@ impl OverlayedChanges { | |
child_info: &ChildInfo, | ||
) { | ||
let extrinsic_index = self.extrinsic_index(); | ||
let storage_key = child_info.storage_key(); | ||
let (changeset, info) = self.children.entry(storage_key.to_vec()) | ||
.or_insert_with(|| (Default::default(), child_info.to_owned())); | ||
let storage_key = child_info.storage_key().to_vec(); | ||
let changeset = self.top.spawn_child(); | ||
let (changeset, info) = self.children.entry(storage_key).or_insert_with(|| | ||
( | ||
changeset, | ||
child_info.to_owned() | ||
) | ||
); | ||
let updatable = info.try_update(child_info); | ||
debug_assert!(updatable); | ||
changeset.clear_where(|_, _| true, extrinsic_index); | ||
|
@@ -292,9 +294,14 @@ impl OverlayedChanges { | |
prefix: &[u8], | ||
) { | ||
let extrinsic_index = self.extrinsic_index(); | ||
let storage_key = child_info.storage_key(); | ||
let (changeset, info) = self.children.entry(storage_key.to_vec()) | ||
.or_insert_with(|| (Default::default(), child_info.to_owned())); | ||
let storage_key = child_info.storage_key().to_vec(); | ||
let changeset = self.top.spawn_child(); | ||
let (changeset, info) = self.children.entry(storage_key).or_insert_with(|| | ||
( | ||
changeset, | ||
child_info.to_owned() | ||
) | ||
); | ||
let updatable = info.try_update(child_info); | ||
debug_assert!(updatable); | ||
changeset.clear_where(|key, _| key.starts_with(prefix), extrinsic_index); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
why not putting the call to
spawn_child
into or_insert_with fn parameter (we already use a ref to child_info)?