From 318eb043e03b7aabbc3f176e02c15fd4595d16db Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 19 Jun 2019 14:29:07 +0300 Subject: [PATCH] revert back None -> null change --- core/rpc/src/state/mod.rs | 11 ++++++----- core/rpc/src/state/tests.rs | 8 +------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/core/rpc/src/state/mod.rs b/core/rpc/src/state/mod.rs index 0b3b93885e16c..72012f872685c 100644 --- a/core/rpc/src/state/mod.rs +++ b/core/rpc/src/state/mod.rs @@ -268,17 +268,18 @@ impl State 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); } } diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index f8cb19451337a..455dfc5913cdb 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -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,