diff --git a/ethcore/client-traits/src/lib.rs b/ethcore/client-traits/src/lib.rs index 3bdec5fa0..829a0b425 100644 --- a/ethcore/client-traits/src/lib.rs +++ b/ethcore/client-traits/src/lib.rs @@ -274,7 +274,7 @@ pub trait BlockChainClient: /// Get a list of all storage keys in the block `id`, if fat DB is in operation, otherwise `None`. /// If `after` is set the list starts with the following item. - fn list_storage(&self, id: BlockId, account: &Address, after: Option<&H256>, count: u64) -> Option>; + fn list_storage(&self, id: BlockId, account: &Address, after: Option<&H256>, count: Option) -> Option>; /// Get transaction with given hash. fn transaction(&self, id: TransactionId) -> Option; diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 6d3e740d0..8d762155b 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1805,7 +1805,7 @@ impl BlockChainClient for Client { Some(accounts) } - fn list_storage(&self, id: BlockId, account: &Address, after: Option<&H256>, count: u64) -> Option> { + fn list_storage(&self, id: BlockId, account: &Address, after: Option<&H256>, count: Option) -> Option> { if !self.factories.trie.is_fat() { trace!(target: "fatdb", "list_storage: Not a fat DB"); return None; @@ -1846,9 +1846,16 @@ impl BlockChainClient for Client { } } - let keys = iter.filter_map(|item| { - item.ok().map(|(key, _)| H256::from_slice(&key)) - }).take(count as usize).collect(); + let keys = { + let f = iter.filter_map(|item| { + item.ok().map(|(key, _)| H256::from_slice(&key)) + }); + if let Some(count) = count { + f.take(count as usize).collect() + } else { + f.collect() + } + }; Some(keys) } diff --git a/ethcore/src/test_helpers/test_client.rs b/ethcore/src/test_helpers/test_client.rs index dd34f0849..e7b579d65 100644 --- a/ethcore/src/test_helpers/test_client.rs +++ b/ethcore/src/test_helpers/test_client.rs @@ -735,7 +735,7 @@ impl BlockChainClient for TestBlockChainClient { None } - fn list_storage(&self, _id: BlockId, _account: &Address, _after: Option<&H256>, _count: u64) -> Option> { + fn list_storage(&self, _id: BlockId, _account: &Address, _after: Option<&H256>, _count: Option) -> Option> { None } fn transaction(&self, _id: TransactionId) -> Option { diff --git a/parity/blockchain.rs b/parity/blockchain.rs index 3686476c8..008da39ef 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -609,7 +609,7 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> { out.write_fmt(format_args!(", \"storage\": {{")).expect("Write error"); let mut last_storage: Option = None; loop { - let keys = client.list_storage(at, &account, last_storage.as_ref(), 1000).ok_or("Specified block not found")?; + let keys = client.list_storage(at, &account, last_storage.as_ref(), Some(1000)).ok_or("Specified block not found")?; if keys.is_empty() { break; } diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index 21fe836b1..4171df78d 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -203,7 +203,7 @@ where Err(errors::light_unimplemented(None)) } - fn list_storage_keys(&self, _: H160, _: u64, _: Option, _: Option) -> Result>> { + fn list_storage_keys(&self, _: H160, _: Option, _: Option, _: Option) -> Result>> { Err(errors::light_unimplemented(None)) } diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 2905324d6..2151ecc94 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -222,7 +222,7 @@ impl Parity for ParityClient where .map(|a| a.into_iter().map(Into::into).collect())) } - fn list_storage_keys(&self, address: H160, count: u64, after: Option, block_number: Option) -> Result>> { + fn list_storage_keys(&self, address: H160, count: Option, after: Option, block_number: Option) -> Result>> { let number = match block_number.unwrap_or_default() { BlockNumber::Pending => { warn!("BlockNumber::Pending is unsupported"); diff --git a/rpc/src/v1/traits/parity.rs b/rpc/src/v1/traits/parity.rs index c57b758c9..6cd09e432 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -117,7 +117,7 @@ pub trait Parity { /// Returns all storage keys of the given address (first parameter) if Fat DB is enabled (`--fat-db`), /// or null if not. #[rpc(name = "parity_listStorageKeys")] - fn list_storage_keys(&self, H160, u64, Option, Option) -> Result>>; + fn list_storage_keys(&self, H160, Option, Option, Option) -> Result>>; /// Encrypt some data with a public key under ECIES. /// First parameter is the 512-byte destination public key, second is the message.