Skip to content

Commit

Permalink
revert back None -> null change
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik committed Jun 19, 2019
1 parent 0475ed9 commit 318eb04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 6 additions & 5 deletions core/rpc/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,18 @@ impl<B, E, Block: BlockT, RA> State<B, E, Block, RA> where
for key in keys {
let (has_changed, data) = {
let curr_data = self.client.storage(&id, key)?;
match last_values.get(key) {
Some(prev_data) => (curr_data != *prev_data, curr_data),
None => (true, curr_data),
}
let prev_data = last_values.get(key).and_then(|x| x.as_ref());
(curr_data.as_ref() != prev_data, curr_data)
};
if has_changed {
block_changes.changes.push((key.clone(), data.clone()));
}
last_values.insert(key.clone(), data);
}
if !block_changes.changes.is_empty() {

// always insert entry for the first block, because we're claiming to provide values of
// all keys in this entry (if key has None value, it will be missing from the changes field)
if changes.is_empty() || !block_changes.changes.is_empty() {
changes.push(block_changes);
}
}
Expand Down
8 changes: 1 addition & 7 deletions core/rpc/src/state/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,7 @@ fn should_query_storage() {
let mut expected = vec![
StorageChangeSet {
block: genesis_hash,
changes: vec![
(StorageKey(vec![1]), None),
(StorageKey(vec![2]), None),
(StorageKey(vec![3]), None),
(StorageKey(vec![4]), None),
(StorageKey(vec![5]), None),
],
changes: vec![],
},
StorageChangeSet {
block: block1_hash,
Expand Down

0 comments on commit 318eb04

Please sign in to comment.