Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Extened API
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Nov 28, 2016
1 parent c7b359f commit fa45413
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions parity/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,9 @@ fn execute_export_state(cmd: ExportState) -> Result<String, String> {
}

for account in accounts.into_iter() {

let balance = client.balance(&account, at).unwrap_or_else(U256::zero);

if cmd.min_balance.map_or(false, |m| balance < m) || cmd.max_balance.map_or(false, |m| balance > m) {
last = Some(account);
continue; //filtered out
}

Expand Down
11 changes: 6 additions & 5 deletions rpc/src/v1/impls/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use ethstore::random_phrase;
use ethsync::{SyncProvider, ManageNetwork};
use ethcore::miner::MinerService;
use ethcore::client::{MiningBlockChainClient};
use ethcore::ids::BlockID;
use ethcore::mode::Mode;
use ethcore::account_provider::AccountProvider;

Expand All @@ -38,9 +37,11 @@ use v1::types::{
Bytes, U256, H160, H256, H512,
Peers, Transaction, RpcSettings, Histogram,
TransactionStats, LocalTransactionStatus,
BlockNumber,
};
use v1::helpers::{errors, SigningQueue, SignerService, NetworkSettings};
use v1::helpers::dispatch::DEFAULT_MAC;
use v1::helpers::auto_args::Trailing;

/// Parity implementation.
pub struct ParityClient<C, M, S: ?Sized> where
Expand Down Expand Up @@ -234,19 +235,19 @@ impl<C, M, S: ?Sized> Parity for ParityClient<C, M, S> where
Ok(Brain::new(phrase).generate().unwrap().address().into())
}

fn list_accounts(&self, after: Option<H160>, count: u64) -> Result<Option<Vec<H160>>, Error> {
fn list_accounts(&self, count: u64, after: Option<H160>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H160>>, Error> {
try!(self.active());

Ok(take_weak!(self.client)
.list_accounts(BlockID::Latest, after.map(Into::into).as_ref(), count)
.list_accounts(block_number.0.into(), after.map(Into::into).as_ref(), count)
.map(|a| a.into_iter().map(Into::into).collect()))
}

fn list_storage_keys(&self, address: H160, after: Option<H256>, count: u64) -> Result<Option<Vec<H256>>, Error> {
fn list_storage_keys(&self, address: H160, count: u64, after: Option<H256>, block_number: Trailing<BlockNumber>) -> Result<Option<Vec<H256>>, Error> {
try!(self.active());

Ok(take_weak!(self.client)
.list_storage(BlockID::Latest, &address.into(), after.map(Into::into).as_ref(), count)
.list_storage(block_number.0.into(), &address.into(), after.map(Into::into).as_ref(), count)
.map(|a| a.into_iter().map(Into::into).collect()))
}

Expand Down
7 changes: 4 additions & 3 deletions rpc/src/v1/traits/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
use jsonrpc_core::Error;

use std::collections::BTreeMap;
use v1::helpers::auto_args::Wrap;
use v1::helpers::auto_args::{Wrap, Trailing};
use v1::types::{
H160, H256, H512, U256, Bytes,
Peers, Transaction, RpcSettings, Histogram,
TransactionStats, LocalTransactionStatus,
BlockNumber
};

build_rpc_trait! {
Expand Down Expand Up @@ -103,12 +104,12 @@ build_rpc_trait! {

/// Returns all addresses if Fat DB is enabled (`--fat-db`), or null if not.
#[rpc(name = "parity_listAccounts")]
fn list_accounts(&self, Option<H160>, u64) -> Result<Option<Vec<H160>>, Error>;
fn list_accounts(&self, u64, Option<H160>, Trailing<BlockNumber>) -> Result<Option<Vec<H160>>, Error>;

/// 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, Option<H256>, u64) -> Result<Option<Vec<H256>>, Error>;
fn list_storage_keys(&self, H160, u64, Option<H256>, Trailing<BlockNumber>) -> Result<Option<Vec<H256>>, Error>;

/// Encrypt some data with a public key under ECIES.
/// First parameter is the 512-byte destination public key, second is the message.
Expand Down

0 comments on commit fa45413

Please sign in to comment.