Update jsonrpc dependencies and rewrite dapps to futures. (#6522)
* Bump version. * Fix RPC crate. * Fix BoxFuture in crates. * Compiles and passes tests! * Get rid of .boxed() * Fixing issues with the UI. * Remove minihttp. Support threads. * Reimplement files serving to do it in chunks. * Increase chunk size. * Remove some unecessary copying. * Fix tests. * Fix stratum warning and ipfs todo. * Switch to proper branch of jsonrpc. * Update Cargo.lock. * Update docs. * Include dapps-glue in workspace. * fixed merge artifacts * Fix test compilation.
This commit is contained in:
committed by
Arkadiy Paronyan
parent
492da38d67
commit
e8b418ca03
@@ -20,7 +20,6 @@ use std::thread;
|
||||
use std::time::{Instant, Duration};
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::{self, future, BoxFuture, Future};
|
||||
use rlp::{self, UntrustedRlp};
|
||||
use time::get_time;
|
||||
use bigint::prelude::U256;
|
||||
@@ -41,7 +40,8 @@ use ethcore::transaction::SignedTransaction;
|
||||
use ethcore::snapshot::SnapshotService;
|
||||
use ethsync::{SyncProvider};
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::future;
|
||||
use jsonrpc_macros::Trailing;
|
||||
|
||||
use v1::helpers::{errors, limit_logs, fake_sign};
|
||||
@@ -318,19 +318,15 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
}
|
||||
}
|
||||
|
||||
fn author(&self, meta: Metadata) -> BoxFuture<RpcH160, Error> {
|
||||
fn author(&self, meta: Metadata) -> Result<RpcH160, Error> {
|
||||
let dapp = meta.dapp_id();
|
||||
|
||||
let author = move || {
|
||||
let mut miner = self.miner.author();
|
||||
if miner == 0.into() {
|
||||
miner = self.dapp_accounts(dapp.into())?.get(0).cloned().unwrap_or_default();
|
||||
}
|
||||
let mut miner = self.miner.author();
|
||||
if miner == 0.into() {
|
||||
miner = self.dapp_accounts(dapp.into())?.get(0).cloned().unwrap_or_default();
|
||||
}
|
||||
|
||||
Ok(RpcH160::from(miner))
|
||||
};
|
||||
|
||||
futures::done(author()).boxed()
|
||||
Ok(RpcH160::from(miner))
|
||||
}
|
||||
|
||||
fn is_mining(&self) -> Result<bool, Error> {
|
||||
@@ -345,15 +341,11 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
Ok(RpcU256::from(default_gas_price(&*self.client, &*self.miner)))
|
||||
}
|
||||
|
||||
fn accounts(&self, meta: Metadata) -> BoxFuture<Vec<RpcH160>, Error> {
|
||||
fn accounts(&self, meta: Metadata) -> Result<Vec<RpcH160>, Error> {
|
||||
let dapp = meta.dapp_id();
|
||||
|
||||
let accounts = move || {
|
||||
let accounts = self.dapp_accounts(dapp.into())?;
|
||||
Ok(accounts.into_iter().map(Into::into).collect())
|
||||
};
|
||||
|
||||
futures::done(accounts()).boxed()
|
||||
let accounts = self.dapp_accounts(dapp.into())?;
|
||||
Ok(accounts.into_iter().map(Into::into).collect())
|
||||
}
|
||||
|
||||
fn block_number(&self) -> Result<RpcU256, Error> {
|
||||
@@ -371,7 +363,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
None => Err(errors::state_pruned()),
|
||||
};
|
||||
|
||||
future::done(res).boxed()
|
||||
Box::new(future::done(res))
|
||||
}
|
||||
|
||||
fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing<BlockNumber>) -> BoxFuture<RpcH256, Error> {
|
||||
@@ -386,7 +378,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
None => Err(errors::state_pruned()),
|
||||
};
|
||||
|
||||
future::done(res).boxed()
|
||||
Box::new(future::done(res))
|
||||
}
|
||||
|
||||
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
@@ -411,38 +403,37 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
}
|
||||
};
|
||||
|
||||
future::done(res).boxed()
|
||||
Box::new(future::done(res))
|
||||
}
|
||||
|
||||
fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
future::ok(self.client.block(BlockId::Hash(hash.into()))
|
||||
.map(|block| block.transactions_count().into())).boxed()
|
||||
Box::new(future::ok(self.client.block(BlockId::Hash(hash.into()))
|
||||
.map(|block| block.transactions_count().into())))
|
||||
}
|
||||
|
||||
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
future::ok(match num {
|
||||
Box::new(future::ok(match num {
|
||||
BlockNumber::Pending => Some(
|
||||
self.miner.status().transactions_in_pending_block.into()
|
||||
),
|
||||
_ =>
|
||||
self.client.block(num.into())
|
||||
.map(|block| block.transactions_count().into())
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
future::ok(self.client.block(BlockId::Hash(hash.into()))
|
||||
.map(|block| block.uncles_count().into()))
|
||||
.boxed()
|
||||
Box::new(future::ok(self.client.block(BlockId::Hash(hash.into()))
|
||||
.map(|block| block.uncles_count().into())))
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
future::ok(match num {
|
||||
Box::new(future::ok(match num {
|
||||
BlockNumber::Pending => Some(0.into()),
|
||||
_ => self.client.block(num.into())
|
||||
.map(|block| block.uncles_count().into()
|
||||
),
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn code_at(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
@@ -456,15 +447,15 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
None => Err(errors::state_pruned()),
|
||||
};
|
||||
|
||||
future::done(res).boxed()
|
||||
Box::new(future::done(res))
|
||||
}
|
||||
|
||||
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
future::done(self.block(BlockId::Hash(hash.into()), include_txs)).boxed()
|
||||
Box::new(future::done(self.block(BlockId::Hash(hash.into()), include_txs)))
|
||||
}
|
||||
|
||||
fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
future::done(self.block(num.into(), include_txs)).boxed()
|
||||
Box::new(future::done(self.block(num.into(), include_txs)))
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, hash: RpcH256) -> Result<Option<Transaction>, Error> {
|
||||
@@ -521,7 +512,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
|
||||
let logs = limit_logs(logs, filter.limit);
|
||||
|
||||
future::ok(logs).boxed()
|
||||
Box::new(future::ok(logs))
|
||||
}
|
||||
|
||||
fn work(&self, no_new_work_timeout: Trailing<u64>) -> Result<Work, Error> {
|
||||
@@ -615,30 +606,24 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
|
||||
fn call(&self, meta: Self::Metadata, request: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
let request = CallRequest::into(request);
|
||||
let signed = match fake_sign::sign_call(&self.client, &self.miner, request, meta.is_dapp()) {
|
||||
Ok(signed) => signed,
|
||||
Err(e) => return future::err(e).boxed(),
|
||||
};
|
||||
let signed = try_bf!(fake_sign::sign_call(&self.client, &self.miner, request, meta.is_dapp()));
|
||||
|
||||
let num = num.unwrap_or_default();
|
||||
let result = self.client.call(&signed, Default::default(), num.into());
|
||||
|
||||
future::done(result
|
||||
Box::new(future::done(result
|
||||
.map(|b| b.output.into())
|
||||
.map_err(errors::call)
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
|
||||
fn estimate_gas(&self, meta: Self::Metadata, request: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
let request = CallRequest::into(request);
|
||||
let signed = match fake_sign::sign_call(&self.client, &self.miner, request, meta.is_dapp()) {
|
||||
Ok(signed) => signed,
|
||||
Err(e) => return future::err(e).boxed(),
|
||||
};
|
||||
future::done(self.client.estimate_gas(&signed, num.unwrap_or_default().into())
|
||||
let signed = try_bf!(fake_sign::sign_call(&self.client, &self.miner, request, meta.is_dapp()));
|
||||
Box::new(future::done(self.client.estimate_gas(&signed, num.unwrap_or_default().into())
|
||||
.map(Into::into)
|
||||
.map_err(errors::call)
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
|
||||
fn compile_lll(&self, _: String) -> Result<Bytes, Error> {
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
use std::sync::Arc;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use jsonrpc_core::*;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::filter::Filter as EthcoreFilter;
|
||||
use ethcore::client::{BlockChainClient, BlockId};
|
||||
use bigint::hash::H256;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use futures::{future, Future, BoxFuture};
|
||||
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::{future, Future};
|
||||
use jsonrpc_core::futures::future::Either;
|
||||
use v1::traits::EthFilter;
|
||||
use v1::types::{BlockNumber, Index, Filter, FilterChanges, Log, H256 as RpcH256, U256 as RpcU256};
|
||||
use v1::helpers::{PollFilter, PollManager, limit_logs};
|
||||
@@ -89,7 +89,7 @@ impl<C, M> Filterable for EthFilterClient<C, M> where C: BlockChainClient, M: Mi
|
||||
}
|
||||
|
||||
fn logs(&self, filter: EthcoreFilter) -> BoxFuture<Vec<Log>, Error> {
|
||||
future::ok(self.client.logs(filter).into_iter().map(Into::into).collect()).boxed()
|
||||
Box::new(future::ok(self.client.logs(filter).into_iter().map(Into::into).collect()))
|
||||
}
|
||||
|
||||
fn pending_logs(&self, block_number: u64, filter: &EthcoreFilter) -> Vec<Log> {
|
||||
@@ -125,8 +125,8 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
|
||||
fn filter_changes(&self, index: Index) -> BoxFuture<FilterChanges, Error> {
|
||||
let mut polls = self.polls().lock();
|
||||
match polls.poll_mut(&index.value()) {
|
||||
None => future::ok(FilterChanges::Empty).boxed(),
|
||||
Box::new(match polls.poll_mut(&index.value()) {
|
||||
None => Either::A(future::ok(FilterChanges::Empty)),
|
||||
Some(filter) => match *filter {
|
||||
PollFilter::Block(ref mut block_number) => {
|
||||
// + 1, cause we want to return hashes including current block hash.
|
||||
@@ -138,7 +138,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
|
||||
*block_number = current_number;
|
||||
|
||||
future::ok(FilterChanges::Hashes(hashes)).boxed()
|
||||
Either::A(future::ok(FilterChanges::Hashes(hashes)))
|
||||
},
|
||||
PollFilter::PendingTransaction(ref mut previous_hashes) => {
|
||||
// get hashes of pending transactions
|
||||
@@ -162,7 +162,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
*previous_hashes = current_hashes;
|
||||
|
||||
// return new hashes
|
||||
future::ok(FilterChanges::Hashes(new_hashes)).boxed()
|
||||
Either::A(future::ok(FilterChanges::Hashes(new_hashes)))
|
||||
},
|
||||
PollFilter::Logs(ref mut block_number, ref mut previous_logs, ref filter) => {
|
||||
// retrive the current block number
|
||||
@@ -200,14 +200,13 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
|
||||
// retrieve logs in range from_block..min(BlockId::Latest..to_block)
|
||||
let limit = filter.limit;
|
||||
self.logs(filter)
|
||||
Either::B(self.logs(filter)
|
||||
.map(move |mut logs| { logs.extend(pending); logs }) // append fetched pending logs
|
||||
.map(move |logs| limit_logs(logs, limit)) // limit the logs
|
||||
.map(FilterChanges::Logs)
|
||||
.boxed()
|
||||
.map(FilterChanges::Logs))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn filter_logs(&self, index: Index) -> BoxFuture<Vec<Log>, Error> {
|
||||
@@ -217,7 +216,7 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
match polls.poll(&index.value()) {
|
||||
Some(&PollFilter::Logs(ref _block_number, ref _previous_log, ref filter)) => filter.clone(),
|
||||
// just empty array
|
||||
_ => return future::ok(Vec::new()).boxed(),
|
||||
_ => return Box::new(future::ok(Vec::new())),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -235,11 +234,10 @@ impl<T: Filterable + Send + Sync + 'static> EthFilter for T {
|
||||
// retrieve logs asynchronously, appending pending logs.
|
||||
let limit = filter.limit;
|
||||
let logs = self.logs(filter);
|
||||
let res = logs
|
||||
Box::new(logs
|
||||
.map(move |mut logs| { logs.extend(pending); logs })
|
||||
.map(move |logs| limit_logs(logs, limit))
|
||||
.boxed();
|
||||
res
|
||||
)
|
||||
}
|
||||
|
||||
fn uninstall_filter(&self, index: Index) -> Result<bool, Error> {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
use std::sync::Arc;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use futures::{self, future, BoxFuture, Future};
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::{self, Future, IntoFuture};
|
||||
use jsonrpc_macros::Trailing;
|
||||
use jsonrpc_macros::pubsub::{Sink, Subscriber};
|
||||
use jsonrpc_pubsub::SubscriptionId;
|
||||
@@ -131,8 +131,10 @@ impl<C> ChainNotificationHandler<C> {
|
||||
}
|
||||
}
|
||||
|
||||
fn notify_logs<F>(&self, enacted: &[H256], logs: F) where
|
||||
F: Fn(EthFilter) -> BoxFuture<Vec<Log>, Error>,
|
||||
fn notify_logs<F, T>(&self, enacted: &[H256], logs: F) where
|
||||
F: Fn(EthFilter) -> T,
|
||||
T: IntoFuture<Item = Vec<Log>, Error = Error>,
|
||||
T::Future: Send + 'static,
|
||||
{
|
||||
for &(ref subscriber, ref filter) in self.logs_subscribers.read().values() {
|
||||
let logs = futures::future::join_all(enacted
|
||||
@@ -141,7 +143,7 @@ impl<C> ChainNotificationHandler<C> {
|
||||
let mut filter = filter.clone();
|
||||
filter.from_block = BlockId::Hash(*hash);
|
||||
filter.to_block = filter.from_block.clone();
|
||||
logs(filter)
|
||||
logs(filter).into_future()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
@@ -224,15 +226,15 @@ impl<C: BlockChainClient> ChainNotify for ChainNotificationHandler<C> {
|
||||
|
||||
// Enacted logs
|
||||
self.notify_logs(&enacted, |filter| {
|
||||
future::ok(self.client.logs(filter).into_iter().map(Into::into).collect()).boxed()
|
||||
Ok(self.client.logs(filter).into_iter().map(Into::into).collect())
|
||||
});
|
||||
|
||||
// Retracted logs
|
||||
self.notify_logs(&retracted, |filter| {
|
||||
future::ok(self.client.logs(filter).into_iter().map(Into::into).map(|mut log: Log| {
|
||||
Ok(self.client.logs(filter).into_iter().map(Into::into).map(|mut log: Log| {
|
||||
log.log_type = "removed".into();
|
||||
log
|
||||
}).collect()).boxed()
|
||||
}).collect())
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -270,10 +272,10 @@ impl<C: Send + Sync + 'static> EthPubSub for EthPubSubClient<C> {
|
||||
let _ = subscriber.reject(error);
|
||||
}
|
||||
|
||||
fn unsubscribe(&self, id: SubscriptionId) -> BoxFuture<bool, Error> {
|
||||
fn unsubscribe(&self, id: SubscriptionId) -> Result<bool, Error> {
|
||||
let res = self.heads_subscribers.write().remove(&id).is_some();
|
||||
let res2 = self.logs_subscribers.write().remove(&id).is_some();
|
||||
|
||||
future::ok(res || res2).boxed()
|
||||
Ok(res || res2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
//! Eth RPC interface for the light client.
|
||||
|
||||
// TODO: remove when complete.
|
||||
#![allow(unused_imports, unused_variables)]
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::{future, Future};
|
||||
use jsonrpc_core::futures::future::Either;
|
||||
use jsonrpc_macros::Trailing;
|
||||
|
||||
use light::cache::Cache as LightDataCache;
|
||||
@@ -30,25 +29,20 @@ use light::{cht, TransactionQueue};
|
||||
use light::on_demand::{request, OnDemand};
|
||||
|
||||
use ethcore::account_provider::{AccountProvider, DappId};
|
||||
use ethcore::basic_account::BasicAccount;
|
||||
use ethcore::encoded;
|
||||
use ethcore::executed::{Executed, ExecutionError};
|
||||
use ethcore::ids::BlockId;
|
||||
use ethcore::filter::Filter as EthcoreFilter;
|
||||
use ethcore::transaction::{Action, SignedTransaction, Transaction as EthTransaction};
|
||||
use ethcore::transaction::SignedTransaction;
|
||||
use ethsync::LightSync;
|
||||
use rlp::UntrustedRlp;
|
||||
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP};
|
||||
use bigint::prelude::U256;
|
||||
use parking_lot::{RwLock, Mutex};
|
||||
|
||||
use futures::{future, Future, BoxFuture, IntoFuture};
|
||||
use futures::sync::oneshot;
|
||||
|
||||
use v1::impls::eth_filter::Filterable;
|
||||
use v1::helpers::{CallRequest as CRequest, errors, limit_logs, dispatch};
|
||||
use v1::helpers::{errors, limit_logs};
|
||||
use v1::helpers::{PollFilter, PollManager};
|
||||
use v1::helpers::block_import::is_major_importing;
|
||||
use v1::helpers::light_fetch::LightFetch;
|
||||
use v1::traits::Eth;
|
||||
use v1::types::{
|
||||
@@ -58,8 +52,6 @@ use v1::types::{
|
||||
};
|
||||
use v1::metadata::Metadata;
|
||||
|
||||
use util::Address;
|
||||
|
||||
const NO_INVALID_BACK_REFS: &'static str = "Fails only on invalid back-references; back-references here known to be valid; qed";
|
||||
|
||||
/// Light client `ETH` (and filter) RPC.
|
||||
@@ -162,10 +154,10 @@ impl<T: LightChainClient + 'static> EthClient<T> {
|
||||
};
|
||||
|
||||
// get the block itself.
|
||||
self.fetcher().block(id).and_then(move |block| {
|
||||
Box::new(self.fetcher().block(id).and_then(move |block| {
|
||||
// then fetch the total difficulty (this is much easier after getting the block).
|
||||
match client.score(id) {
|
||||
Some(score) => future::ok(fill_rich(block, Some(score))).boxed(),
|
||||
Some(score) => Either::A(future::ok(fill_rich(block, Some(score)))),
|
||||
None => {
|
||||
// make a CHT request to fetch the chain score.
|
||||
let req = cht::block_to_cht_number(block.number())
|
||||
@@ -181,7 +173,7 @@ impl<T: LightChainClient + 'static> EthClient<T> {
|
||||
.expect("genesis always stored; qed")
|
||||
.difficulty();
|
||||
|
||||
return future::ok(fill_rich(block, Some(score))).boxed()
|
||||
return Either::A(future::ok(fill_rich(block, Some(score))))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -191,7 +183,7 @@ impl<T: LightChainClient + 'static> EthClient<T> {
|
||||
// - we get a score, and our hash is canonical.
|
||||
let maybe_fut = sync.with_context(move |ctx| on_demand.request(ctx, req).expect(NO_INVALID_BACK_REFS));
|
||||
match maybe_fut {
|
||||
Some(fut) => fut
|
||||
Some(fut) => Either::B(fut
|
||||
.map(move |(hash, score)| {
|
||||
let score = if hash == block.hash() {
|
||||
Some(score)
|
||||
@@ -199,13 +191,13 @@ impl<T: LightChainClient + 'static> EthClient<T> {
|
||||
None
|
||||
};
|
||||
|
||||
fill_rich(block, score)
|
||||
}).map_err(errors::on_demand_cancel).boxed(),
|
||||
None => return future::err(errors::network_disabled()).boxed(),
|
||||
fill_rich(block, score)
|
||||
}).map_err(errors::on_demand_cancel)),
|
||||
None => Either::A(future::err(errors::network_disabled())),
|
||||
}
|
||||
}
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,8 +227,8 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fn author(&self, _meta: Self::Metadata) -> BoxFuture<RpcH160, Error> {
|
||||
future::ok(Default::default()).boxed()
|
||||
fn author(&self, _meta: Self::Metadata) -> Result<RpcH160, Error> {
|
||||
Ok(Default::default())
|
||||
}
|
||||
|
||||
fn is_mining(&self) -> Result<bool, Error> {
|
||||
@@ -254,16 +246,14 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
.unwrap_or_else(Default::default))
|
||||
}
|
||||
|
||||
fn accounts(&self, meta: Metadata) -> BoxFuture<Vec<RpcH160>, Error> {
|
||||
fn accounts(&self, meta: Metadata) -> Result<Vec<RpcH160>, Error> {
|
||||
let dapp: DappId = meta.dapp_id().into();
|
||||
|
||||
let accounts = self.accounts
|
||||
self.accounts
|
||||
.note_dapp_used(dapp.clone())
|
||||
.and_then(|_| self.accounts.dapp_addresses(dapp))
|
||||
.map_err(|e| errors::account("Could not fetch accounts.", e))
|
||||
.map(|accs| accs.into_iter().map(Into::<RpcH160>::into).collect());
|
||||
|
||||
future::done(accounts).boxed()
|
||||
.map(|accs| accs.into_iter().map(Into::<RpcH160>::into).collect())
|
||||
}
|
||||
|
||||
fn block_number(&self) -> Result<RpcU256, Error> {
|
||||
@@ -271,93 +261,93 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}
|
||||
|
||||
fn balance(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
self.fetcher().account(address.into(), num.unwrap_or_default().into())
|
||||
.map(|acc| acc.map_or(0.into(), |a| a.balance).into()).boxed()
|
||||
Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().into())
|
||||
.map(|acc| acc.map_or(0.into(), |a| a.balance).into()))
|
||||
}
|
||||
|
||||
fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Trailing<BlockNumber>) -> BoxFuture<RpcH256, Error> {
|
||||
future::err(errors::unimplemented(None)).boxed()
|
||||
Box::new(future::err(errors::unimplemented(None)))
|
||||
}
|
||||
|
||||
fn block_by_hash(&self, hash: RpcH256, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
self.rich_block(BlockId::Hash(hash.into()), include_txs).map(Some).boxed()
|
||||
Box::new(self.rich_block(BlockId::Hash(hash.into()), include_txs).map(Some))
|
||||
}
|
||||
|
||||
fn block_by_number(&self, num: BlockNumber, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
self.rich_block(num.into(), include_txs).map(Some).boxed()
|
||||
Box::new(self.rich_block(num.into(), include_txs).map(Some))
|
||||
}
|
||||
|
||||
fn transaction_count(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
self.fetcher().account(address.into(), num.unwrap_or_default().into())
|
||||
.map(|acc| acc.map_or(0.into(), |a| a.nonce).into()).boxed()
|
||||
Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().into())
|
||||
.map(|acc| acc.map_or(0.into(), |a| a.nonce).into()))
|
||||
}
|
||||
|
||||
fn block_transaction_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
|
||||
|
||||
self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| {
|
||||
Box::new(self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| {
|
||||
if hdr.transactions_root() == KECCAK_NULL_RLP {
|
||||
future::ok(Some(U256::from(0).into())).boxed()
|
||||
Either::A(future::ok(Some(U256::from(0).into())))
|
||||
} else {
|
||||
sync.with_context(|ctx| on_demand.request(ctx, request::Body(hdr.into())))
|
||||
.map(|x| x.expect(NO_INVALID_BACK_REFS))
|
||||
.map(|x| x.map(|b| Some(U256::from(b.transactions_count()).into())))
|
||||
.map(|x| x.map_err(errors::on_demand_cancel).boxed())
|
||||
.unwrap_or_else(|| future::err(errors::network_disabled()).boxed())
|
||||
.map(|x| Either::B(x.map_err(errors::on_demand_cancel)))
|
||||
.unwrap_or_else(|| Either::A(future::err(errors::network_disabled())))
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn block_transaction_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
|
||||
|
||||
self.fetcher().header(num.into()).and_then(move |hdr| {
|
||||
Box::new(self.fetcher().header(num.into()).and_then(move |hdr| {
|
||||
if hdr.transactions_root() == KECCAK_NULL_RLP {
|
||||
future::ok(Some(U256::from(0).into())).boxed()
|
||||
Either::A(future::ok(Some(U256::from(0).into())))
|
||||
} else {
|
||||
sync.with_context(|ctx| on_demand.request(ctx, request::Body(hdr.into())))
|
||||
.map(|x| x.expect(NO_INVALID_BACK_REFS))
|
||||
.map(|x| x.map(|b| Some(U256::from(b.transactions_count()).into())))
|
||||
.map(|x| x.map_err(errors::on_demand_cancel).boxed())
|
||||
.unwrap_or_else(|| future::err(errors::network_disabled()).boxed())
|
||||
.map(|x| Either::B(x.map_err(errors::on_demand_cancel)))
|
||||
.unwrap_or_else(|| Either::A(future::err(errors::network_disabled())))
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_hash(&self, hash: RpcH256) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
|
||||
|
||||
self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| {
|
||||
Box::new(self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| {
|
||||
if hdr.uncles_hash() == KECCAK_EMPTY_LIST_RLP {
|
||||
future::ok(Some(U256::from(0).into())).boxed()
|
||||
Either::A(future::ok(Some(U256::from(0).into())))
|
||||
} else {
|
||||
sync.with_context(|ctx| on_demand.request(ctx, request::Body(hdr.into())))
|
||||
.map(|x| x.expect(NO_INVALID_BACK_REFS))
|
||||
.map(|x| x.map(|b| Some(U256::from(b.uncles_count()).into())))
|
||||
.map(|x| x.map_err(errors::on_demand_cancel).boxed())
|
||||
.unwrap_or_else(|| future::err(errors::network_disabled()).boxed())
|
||||
.map(|x| Either::B(x.map_err(errors::on_demand_cancel)))
|
||||
.unwrap_or_else(|| Either::A(future::err(errors::network_disabled())))
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn block_uncles_count_by_number(&self, num: BlockNumber) -> BoxFuture<Option<RpcU256>, Error> {
|
||||
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
|
||||
|
||||
self.fetcher().header(num.into()).and_then(move |hdr| {
|
||||
Box::new(self.fetcher().header(num.into()).and_then(move |hdr| {
|
||||
if hdr.uncles_hash() == KECCAK_EMPTY_LIST_RLP {
|
||||
future::ok(Some(U256::from(0).into())).boxed()
|
||||
Either::B(future::ok(Some(U256::from(0).into())))
|
||||
} else {
|
||||
sync.with_context(|ctx| on_demand.request(ctx, request::Body(hdr.into())))
|
||||
.map(|x| x.expect(NO_INVALID_BACK_REFS))
|
||||
.map(|x| x.map(|b| Some(U256::from(b.uncles_count()).into())))
|
||||
.map(|x| x.map_err(errors::on_demand_cancel).boxed())
|
||||
.unwrap_or_else(|| future::err(errors::network_disabled()).boxed())
|
||||
.map(|x| Either::A(x.map_err(errors::on_demand_cancel)))
|
||||
.unwrap_or_else(|| Either::B(future::err(errors::network_disabled())))
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn code_at(&self, address: RpcH160, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
future::err(errors::unimplemented(None)).boxed()
|
||||
fn code_at(&self, _address: RpcH160, _num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
Box::new(future::err(errors::unimplemented(None)))
|
||||
}
|
||||
|
||||
fn send_raw_transaction(&self, raw: Bytes) -> Result<RpcH256, Error> {
|
||||
@@ -385,45 +375,45 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
}
|
||||
|
||||
fn call(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<Bytes, Error> {
|
||||
self.fetcher().proved_execution(req, num).and_then(|res| {
|
||||
Box::new(self.fetcher().proved_execution(req, num).and_then(|res| {
|
||||
match res {
|
||||
Ok(exec) => Ok(exec.output.into()),
|
||||
Err(e) => Err(errors::execution(e)),
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn estimate_gas(&self, _meta: Self::Metadata, req: CallRequest, num: Trailing<BlockNumber>) -> BoxFuture<RpcU256, Error> {
|
||||
// TODO: binary chop for more accurate estimates.
|
||||
self.fetcher().proved_execution(req, num).and_then(|res| {
|
||||
Box::new(self.fetcher().proved_execution(req, num).and_then(|res| {
|
||||
match res {
|
||||
Ok(exec) => Ok((exec.refunded + exec.gas_used).into()),
|
||||
Err(e) => Err(errors::execution(e)),
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn transaction_by_hash(&self, hash: RpcH256) -> Result<Option<Transaction>, Error> {
|
||||
fn transaction_by_hash(&self, _hash: RpcH256) -> Result<Option<Transaction>, Error> {
|
||||
Err(errors::unimplemented(None))
|
||||
}
|
||||
|
||||
fn transaction_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> Result<Option<Transaction>, Error> {
|
||||
fn transaction_by_block_hash_and_index(&self, _hash: RpcH256, _idx: Index) -> Result<Option<Transaction>, Error> {
|
||||
Err(errors::unimplemented(None))
|
||||
}
|
||||
|
||||
fn transaction_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> Result<Option<Transaction>, Error> {
|
||||
fn transaction_by_block_number_and_index(&self, _num: BlockNumber, _idx: Index) -> Result<Option<Transaction>, Error> {
|
||||
Err(errors::unimplemented(None))
|
||||
}
|
||||
|
||||
fn transaction_receipt(&self, hash: RpcH256) -> Result<Option<Receipt>, Error> {
|
||||
fn transaction_receipt(&self, _hash: RpcH256) -> Result<Option<Receipt>, Error> {
|
||||
Err(errors::unimplemented(None))
|
||||
}
|
||||
|
||||
fn uncle_by_block_hash_and_index(&self, hash: RpcH256, idx: Index) -> Result<Option<RichBlock>, Error> {
|
||||
fn uncle_by_block_hash_and_index(&self, _hash: RpcH256, _idx: Index) -> Result<Option<RichBlock>, Error> {
|
||||
Err(errors::unimplemented(None))
|
||||
}
|
||||
|
||||
fn uncle_by_block_number_and_index(&self, num: BlockNumber, idx: Index) -> Result<Option<RichBlock>, Error> {
|
||||
fn uncle_by_block_number_and_index(&self, _num: BlockNumber, _idx: Index) -> Result<Option<RichBlock>, Error> {
|
||||
Err(errors::unimplemented(None))
|
||||
}
|
||||
|
||||
@@ -447,9 +437,8 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
|
||||
fn logs(&self, filter: Filter) -> BoxFuture<Vec<Log>, Error> {
|
||||
let limit = filter.limit;
|
||||
|
||||
Filterable::logs(self, filter.into())
|
||||
.map(move|logs| limit_logs(logs, limit))
|
||||
.boxed()
|
||||
Box::new(Filterable::logs(self, filter.into())
|
||||
.map(move|logs| limit_logs(logs, limit)))
|
||||
}
|
||||
|
||||
fn work(&self, _timeout: Trailing<u64>) -> Result<Work, Error> {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
//! Parity-specific rpc implementation.
|
||||
use std::sync::Arc;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use futures::{future, Future, BoxFuture};
|
||||
|
||||
use util::misc::version_data;
|
||||
|
||||
@@ -31,7 +30,8 @@ use node_health::{NodeHealth, Health};
|
||||
|
||||
use light::client::LightChainClient;
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::Future;
|
||||
use jsonrpc_macros::Trailing;
|
||||
use v1::helpers::{self, errors, ipfs, SigningQueue, SignerService, NetworkSettings};
|
||||
use v1::helpers::dispatch::LightDispatcher;
|
||||
@@ -140,15 +140,14 @@ impl Parity for ParityClient {
|
||||
Ok(store.locked_hardware_accounts().map_err(|e| errors::account("Error communicating with hardware wallet.", e))?)
|
||||
}
|
||||
|
||||
fn default_account(&self, meta: Self::Metadata) -> BoxFuture<H160, Error> {
|
||||
fn default_account(&self, meta: Self::Metadata) -> Result<H160, Error> {
|
||||
let dapp_id = meta.dapp_id();
|
||||
future::ok(self.accounts
|
||||
Ok(self.accounts
|
||||
.dapp_addresses(dapp_id.into())
|
||||
.ok()
|
||||
.and_then(|accounts| accounts.get(0).cloned())
|
||||
.map(|acc| acc.into())
|
||||
.unwrap_or_default()
|
||||
).boxed()
|
||||
.unwrap_or_default())
|
||||
}
|
||||
|
||||
fn transactions_limit(&self) -> Result<usize, Error> {
|
||||
@@ -221,10 +220,9 @@ impl Parity for ParityClient {
|
||||
}
|
||||
|
||||
fn gas_price_histogram(&self) -> BoxFuture<Histogram, Error> {
|
||||
self.light_dispatch.gas_price_corpus()
|
||||
Box::new(self.light_dispatch.gas_price_corpus()
|
||||
.and_then(|corpus| corpus.histogram(10).ok_or_else(errors::not_enough_data))
|
||||
.map(Into::into)
|
||||
.boxed()
|
||||
.map(Into::into))
|
||||
}
|
||||
|
||||
fn unsigned_transactions_count(&self) -> Result<usize, Error> {
|
||||
@@ -316,7 +314,7 @@ impl Parity for ParityClient {
|
||||
}
|
||||
|
||||
fn next_nonce(&self, address: H160) -> BoxFuture<U256, Error> {
|
||||
self.light_dispatch.next_nonce(address.into()).map(Into::into).boxed()
|
||||
Box::new(self.light_dispatch.next_nonce(address.into()).map(Into::into))
|
||||
}
|
||||
|
||||
fn mode(&self) -> Result<String, Error> {
|
||||
@@ -398,20 +396,19 @@ impl Parity for ParityClient {
|
||||
}
|
||||
};
|
||||
|
||||
self.fetcher().header(number.unwrap_or_default().into()).map(from_encoded).boxed()
|
||||
Box::new(self.fetcher().header(number.unwrap_or_default().into()).map(from_encoded))
|
||||
}
|
||||
|
||||
fn ipfs_cid(&self, content: Bytes) -> Result<String, Error> {
|
||||
ipfs::cid(content)
|
||||
}
|
||||
|
||||
fn call(&self, _meta: Self::Metadata, _requests: Vec<CallRequest>, _block: Trailing<BlockNumber>) -> BoxFuture<Vec<Bytes>, Error> {
|
||||
future::err(errors::light_unimplemented(None)).boxed()
|
||||
fn call(&self, _meta: Self::Metadata, _requests: Vec<CallRequest>, _block: Trailing<BlockNumber>) -> Result<Vec<Bytes>, Error> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn node_health(&self) -> BoxFuture<Health, Error> {
|
||||
self.health.health()
|
||||
.map_err(|err| errors::internal("Health API failure.", err))
|
||||
.boxed()
|
||||
Box::new(self.health.health()
|
||||
.map_err(|err| errors::internal("Health API failure.", err)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ use std::sync::Arc;
|
||||
|
||||
use ethsync::ManageNetwork;
|
||||
use fetch::Fetch;
|
||||
use futures::{BoxFuture, Future};
|
||||
use hash::keccak_buffer;
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::Future;
|
||||
use v1::helpers::dapps::DappsService;
|
||||
use v1::helpers::errors;
|
||||
use v1::traits::ParitySet;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
//! Traces api implementation.
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::futures::{future, Future, BoxFuture};
|
||||
use jsonrpc_macros::Trailing;
|
||||
use v1::Metadata;
|
||||
use v1::traits::Traces;
|
||||
@@ -47,12 +46,12 @@ impl Traces for TracesClient {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn call(&self, _meta: Self::Metadata, _request: CallRequest, _flags: TraceOptions, _block: Trailing<BlockNumber>) -> BoxFuture<TraceResults, Error> {
|
||||
future::err(errors::light_unimplemented(None)).boxed()
|
||||
fn call(&self, _meta: Self::Metadata, _request: CallRequest, _flags: TraceOptions, _block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn call_many(&self, _meta: Self::Metadata, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing<BlockNumber>) -> BoxFuture<Vec<TraceResults>, Error> {
|
||||
future::err(errors::light_unimplemented(None)).boxed()
|
||||
fn call_many(&self, _meta: Self::Metadata, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing<BlockNumber>) -> Result<Vec<TraceResults>, Error> {
|
||||
Err(errors::light_unimplemented(None))
|
||||
}
|
||||
|
||||
fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use futures::{future, Future, BoxFuture};
|
||||
|
||||
use util::Address;
|
||||
use util::misc::version_data;
|
||||
@@ -32,12 +31,12 @@ use ethcore::client::{MiningBlockChainClient};
|
||||
use ethcore::ids::BlockId;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::mode::Mode;
|
||||
use ethcore::transaction::SignedTransaction;
|
||||
use ethcore_logger::RotatingLogger;
|
||||
use node_health::{NodeHealth, Health};
|
||||
use updater::{Service as UpdateService};
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::{future, Future};
|
||||
use jsonrpc_macros::Trailing;
|
||||
use v1::helpers::{self, errors, fake_sign, ipfs, SigningQueue, SignerService, NetworkSettings};
|
||||
use v1::helpers::accounts::unwrap_provider;
|
||||
@@ -157,15 +156,14 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
Ok(store.locked_hardware_accounts().map_err(|e| errors::account("Error communicating with hardware wallet.", e))?)
|
||||
}
|
||||
|
||||
fn default_account(&self, meta: Self::Metadata) -> BoxFuture<H160, Error> {
|
||||
fn default_account(&self, meta: Self::Metadata) -> Result<H160, Error> {
|
||||
let dapp_id = meta.dapp_id();
|
||||
future::ok(
|
||||
try_bf!(self.account_provider())
|
||||
.dapp_default_address(dapp_id.into())
|
||||
.map(Into::into)
|
||||
.ok()
|
||||
.unwrap_or_default()
|
||||
).boxed()
|
||||
|
||||
Ok(self.account_provider()?
|
||||
.dapp_default_address(dapp_id.into())
|
||||
.map(Into::into)
|
||||
.ok()
|
||||
.unwrap_or_default())
|
||||
}
|
||||
|
||||
fn transactions_limit(&self) -> Result<usize, Error> {
|
||||
@@ -253,12 +251,12 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
}
|
||||
|
||||
fn gas_price_histogram(&self) -> BoxFuture<Histogram, Error> {
|
||||
future::done(self.client
|
||||
Box::new(future::done(self.client
|
||||
.gas_price_corpus(100)
|
||||
.histogram(10)
|
||||
.ok_or_else(errors::not_enough_data)
|
||||
.map(Into::into)
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
|
||||
fn unsigned_transactions_count(&self) -> Result<usize, Error> {
|
||||
@@ -340,11 +338,11 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
fn next_nonce(&self, address: H160) -> BoxFuture<U256, Error> {
|
||||
let address: Address = address.into();
|
||||
|
||||
future::ok(self.miner.last_nonce(&address)
|
||||
Box::new(future::ok(self.miner.last_nonce(&address)
|
||||
.map(|n| n + 1.into())
|
||||
.unwrap_or_else(|| self.client.latest_nonce(&address))
|
||||
.into()
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
|
||||
fn mode(&self) -> Result<String, Error> {
|
||||
@@ -403,41 +401,37 @@ impl<C, M, U> Parity for ParityClient<C, M, U> where
|
||||
let id: BlockId = number.unwrap_or_default().into();
|
||||
let encoded = match self.client.block_header(id.clone()) {
|
||||
Some(encoded) => encoded,
|
||||
None => return future::err(errors::unknown_block()).boxed(),
|
||||
None => return Box::new(future::err(errors::unknown_block())),
|
||||
};
|
||||
|
||||
future::ok(RichHeader {
|
||||
Box::new(future::ok(RichHeader {
|
||||
inner: encoded.into(),
|
||||
extra_info: self.client.block_extra_info(id).expect(EXTRA_INFO_PROOF),
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn ipfs_cid(&self, content: Bytes) -> Result<String, Error> {
|
||||
ipfs::cid(content)
|
||||
}
|
||||
|
||||
fn call(&self, meta: Self::Metadata, requests: Vec<CallRequest>, block: Trailing<BlockNumber>) -> BoxFuture<Vec<Bytes>, Error> {
|
||||
let requests: Result<Vec<(SignedTransaction, _)>, Error> = requests
|
||||
fn call(&self, meta: Self::Metadata, requests: Vec<CallRequest>, block: Trailing<BlockNumber>) -> Result<Vec<Bytes>, Error> {
|
||||
let requests = requests
|
||||
.into_iter()
|
||||
.map(|request| Ok((
|
||||
fake_sign::sign_call(&self.client, &self.miner, request.into(), meta.is_dapp())?,
|
||||
Default::default()
|
||||
)))
|
||||
.collect();
|
||||
.collect::<Result<Vec<_>, Error>>()?;
|
||||
|
||||
let block = block.unwrap_or_default();
|
||||
let requests = try_bf!(requests);
|
||||
|
||||
let result = self.client.call_many(&requests, block.into())
|
||||
self.client.call_many(&requests, block.into())
|
||||
.map(|res| res.into_iter().map(|res| res.output.into()).collect())
|
||||
.map_err(errors::call);
|
||||
|
||||
future::done(result).boxed()
|
||||
.map_err(errors::call)
|
||||
}
|
||||
|
||||
fn node_health(&self) -> BoxFuture<Health, Error> {
|
||||
self.health.health()
|
||||
.map_err(|err| errors::internal("Health API failure.", err))
|
||||
.boxed()
|
||||
Box::new(self.health.health()
|
||||
.map_err(|err| errors::internal("Health API failure.", err)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ impl ParityAccounts for ParityAccountsClient {
|
||||
|
||||
for (address, account) in account_iter {
|
||||
match accounts.entry(address) {
|
||||
/// Insert only if occupied entry isn't already an account with UUID
|
||||
// Insert only if occupied entry isn't already an account with UUID
|
||||
Entry::Occupied(ref mut occupied) if occupied.get().uuid.is_none() => {
|
||||
occupied.insert(account);
|
||||
},
|
||||
|
||||
@@ -23,11 +23,11 @@ use ethcore::client::MiningBlockChainClient;
|
||||
use ethcore::mode::Mode;
|
||||
use ethsync::ManageNetwork;
|
||||
use fetch::{self, Fetch};
|
||||
use futures::{BoxFuture, Future};
|
||||
use hash::keccak_buffer;
|
||||
use updater::{Service as UpdateService};
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::Future;
|
||||
use v1::helpers::dapps::DappsService;
|
||||
use v1::helpers::errors;
|
||||
use v1::traits::ParitySet;
|
||||
|
||||
@@ -24,8 +24,8 @@ use bigint::prelude::U128;
|
||||
use util::Address;
|
||||
use bytes::ToPretty;
|
||||
|
||||
use futures::{future, Future, BoxFuture};
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::{future, Future};
|
||||
use v1::helpers::errors;
|
||||
use v1::helpers::dispatch::{Dispatcher, SignWith};
|
||||
use v1::helpers::accounts::unwrap_provider;
|
||||
@@ -114,10 +114,10 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
|
||||
|
||||
let default = match default {
|
||||
Ok(default) => default,
|
||||
Err(e) => return future::err(e).boxed(),
|
||||
Err(e) => return Box::new(future::err(e)),
|
||||
};
|
||||
|
||||
dispatcher.fill_optional_fields(request.into(), default, false)
|
||||
Box::new(dispatcher.fill_optional_fields(request.into(), default, false)
|
||||
.and_then(move |filled| {
|
||||
let condition = filled.condition.clone().map(Into::into);
|
||||
dispatcher.sign(accounts, filled, SignWith::Password(password))
|
||||
@@ -131,8 +131,7 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
|
||||
::rlp::encode(&*pending_tx).into_vec().pretty(), chain_id);
|
||||
|
||||
dispatcher.dispatch_transaction(pending_tx).map(Into::into)
|
||||
})
|
||||
.boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn sign_and_send_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256, Error> {
|
||||
|
||||
@@ -20,8 +20,8 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use futures::{self, BoxFuture, Future, Stream, Sink};
|
||||
use jsonrpc_core::{self as core, Error, MetaIoHandler};
|
||||
use jsonrpc_core::futures::{Future, Stream, Sink};
|
||||
use jsonrpc_macros::Trailing;
|
||||
use jsonrpc_macros::pubsub::Subscriber;
|
||||
use jsonrpc_pubsub::SubscriptionId;
|
||||
@@ -94,8 +94,8 @@ impl<S: core::Middleware<Metadata>> PubSub for PubSubClient<S> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parity_unsubscribe(&self, id: SubscriptionId) -> BoxFuture<bool, Error> {
|
||||
fn parity_unsubscribe(&self, id: SubscriptionId) -> Result<bool, Error> {
|
||||
let res = self.poll_manager.write().unsubscribe(&id);
|
||||
futures::future::ok(res).boxed()
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,13 @@ use std::sync::Arc;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::transaction::{SignedTransaction, PendingTransaction};
|
||||
use ethkey;
|
||||
use futures::{future, BoxFuture, Future, IntoFuture};
|
||||
use parity_reactor::Remote;
|
||||
use rlp::UntrustedRlp;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use jsonrpc_core::{futures, Error};
|
||||
use jsonrpc_core::{Error, BoxFuture};
|
||||
use jsonrpc_core::futures::{future, Future, IntoFuture};
|
||||
use jsonrpc_core::futures::future::Either;
|
||||
use jsonrpc_pubsub::SubscriptionId;
|
||||
use jsonrpc_macros::pubsub::{Sink, Subscriber};
|
||||
use v1::helpers::accounts::unwrap_provider;
|
||||
@@ -87,18 +88,11 @@ impl<D: Dispatcher + 'static> SignerClient<D> {
|
||||
T::Future: Send + 'static
|
||||
{
|
||||
let id = id.into();
|
||||
let accounts = try_bf!(self.account_provider());
|
||||
let dispatcher = self.dispatcher.clone();
|
||||
let signer = self.signer.clone();
|
||||
|
||||
let setup = || {
|
||||
Ok((self.account_provider()?, self.signer.clone()))
|
||||
};
|
||||
|
||||
let (accounts, signer) = match setup() {
|
||||
Ok(x) => x,
|
||||
Err(e) => return future::err(e).boxed(),
|
||||
};
|
||||
|
||||
signer.peek(&id).map(|confirmation| {
|
||||
Box::new(signer.peek(&id).map(|confirmation| {
|
||||
let mut payload = confirmation.payload.clone();
|
||||
// Modify payload
|
||||
if let ConfirmationPayload::SendTransaction(ref mut request) = payload {
|
||||
@@ -118,16 +112,16 @@ impl<D: Dispatcher + 'static> SignerClient<D> {
|
||||
}
|
||||
}
|
||||
let fut = f(dispatcher, accounts, payload);
|
||||
fut.into_future().then(move |result| {
|
||||
Either::A(fut.into_future().then(move |result| {
|
||||
// Execute
|
||||
if let Ok(ref response) = result {
|
||||
signer.request_confirmed(id, Ok((*response).clone()));
|
||||
}
|
||||
|
||||
result
|
||||
}).boxed()
|
||||
}))
|
||||
})
|
||||
.unwrap_or_else(|| future::err(errors::invalid_params("Unknown RequestID", id)).boxed())
|
||||
.unwrap_or_else(|| Either::B(future::err(errors::invalid_params("Unknown RequestID", id)))))
|
||||
}
|
||||
|
||||
fn verify_transaction<F>(bytes: Bytes, request: FilledTransactionRequest, process: F) -> Result<ConfirmationResponse, Error> where
|
||||
@@ -178,15 +172,15 @@ impl<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
fn confirm_request(&self, id: U256, modification: TransactionModification, pass: String)
|
||||
-> BoxFuture<ConfirmationResponse, Error>
|
||||
{
|
||||
self.confirm_internal(id, modification, move |dis, accounts, payload| {
|
||||
Box::new(self.confirm_internal(id, modification, move |dis, accounts, payload| {
|
||||
dispatch::execute(dis, accounts, payload, dispatch::SignWith::Password(pass))
|
||||
}).map(|v| v.into_value()).boxed()
|
||||
}).map(|v| v.into_value()))
|
||||
}
|
||||
|
||||
fn confirm_request_with_token(&self, id: U256, modification: TransactionModification, token: String)
|
||||
-> BoxFuture<ConfirmationResponseWithToken, Error>
|
||||
{
|
||||
self.confirm_internal(id, modification, move |dis, accounts, payload| {
|
||||
Box::new(self.confirm_internal(id, modification, move |dis, accounts, payload| {
|
||||
dispatch::execute(dis, accounts, payload, dispatch::SignWith::Token(token))
|
||||
}).and_then(|v| match v {
|
||||
WithToken::No(_) => Err(errors::internal("Unexpected response without token.", "")),
|
||||
@@ -194,7 +188,7 @@ impl<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
result: response,
|
||||
token: token,
|
||||
}),
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn confirm_request_raw(&self, id: U256, bytes: Bytes) -> Result<ConfirmationResponse, Error> {
|
||||
@@ -253,8 +247,8 @@ impl<D: Dispatcher + 'static> Signer for SignerClient<D> {
|
||||
self.subscribers.lock().push(sub)
|
||||
}
|
||||
|
||||
fn unsubscribe_pending(&self, id: SubscriptionId) -> BoxFuture<bool, Error> {
|
||||
fn unsubscribe_pending(&self, id: SubscriptionId) -> Result<bool, Error> {
|
||||
let res = self.subscribers.lock().remove(&id).is_some();
|
||||
futures::future::ok(res).boxed()
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,9 @@ use parking_lot::Mutex;
|
||||
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
|
||||
use futures::{future, BoxFuture, Future};
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::{future, Future};
|
||||
use jsonrpc_core::futures::future::Either;
|
||||
use v1::helpers::{
|
||||
errors, oneshot,
|
||||
DefaultAccount,
|
||||
@@ -115,23 +116,21 @@ impl<D: Dispatcher + 'static> SigningQueueClient<D> {
|
||||
|
||||
let dispatcher = self.dispatcher.clone();
|
||||
let signer = self.signer.clone();
|
||||
dispatch::from_rpc(payload, default_account, &dispatcher)
|
||||
Box::new(dispatch::from_rpc(payload, default_account, &dispatcher)
|
||||
.and_then(move |payload| {
|
||||
let sender = payload.sender();
|
||||
if accounts.is_unlocked(sender) {
|
||||
dispatch::execute(dispatcher, accounts, payload, dispatch::SignWith::Nothing)
|
||||
Either::A(dispatch::execute(dispatcher, accounts, payload, dispatch::SignWith::Nothing)
|
||||
.map(|v| v.into_value())
|
||||
.map(DispatchResult::Value)
|
||||
.boxed()
|
||||
.map(DispatchResult::Value))
|
||||
} else {
|
||||
future::done(
|
||||
Either::B(future::done(
|
||||
signer.add_request(payload, origin)
|
||||
.map(DispatchResult::Promise)
|
||||
.map_err(|_| errors::request_rejected_limit())
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
})
|
||||
.boxed()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,12 +140,12 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture<RpcTransactionRequest, Error> {
|
||||
let accounts = try_bf!(self.account_provider());
|
||||
let default_account = accounts.dapp_default_address(meta.dapp_id().into()).ok().unwrap_or_default();
|
||||
self.dispatcher.fill_optional_fields(transaction.into(), default_account, true).map(Into::into).boxed()
|
||||
Box::new(self.dispatcher.fill_optional_fields(transaction.into(), default_account, true).map(Into::into))
|
||||
}
|
||||
|
||||
fn post_sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
let pending = self.pending.clone();
|
||||
self.dispatch(
|
||||
Box::new(self.dispatch(
|
||||
RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()),
|
||||
DefaultAccount::Provided(address.into()),
|
||||
meta.origin
|
||||
@@ -160,13 +159,12 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
|
||||
RpcEither::Either(id.into())
|
||||
},
|
||||
})
|
||||
.boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn post_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
let pending = self.pending.clone();
|
||||
self.dispatch(RpcConfirmationPayload::SendTransaction(request), meta.dapp_id().into(), meta.origin)
|
||||
Box::new(self.dispatch(RpcConfirmationPayload::SendTransaction(request), meta.dapp_id().into(), meta.origin)
|
||||
.map(move |result| match result {
|
||||
DispatchResult::Value(v) => RpcEither::Or(v),
|
||||
DispatchResult::Promise(promise) => {
|
||||
@@ -177,8 +175,7 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
|
||||
RpcEither::Either(id.into())
|
||||
},
|
||||
})
|
||||
.boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn check_request(&self, id: RpcU256) -> Result<Option<RpcConfirmationResponse>, Error> {
|
||||
@@ -203,7 +200,7 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
let (ready, p) = oneshot::oneshot();
|
||||
|
||||
// when dispatch is complete
|
||||
res.then(move |res| {
|
||||
Box::new(res.then(move |res| {
|
||||
// register callback via the oneshot sender.
|
||||
handle_dispatch(res, move |response| {
|
||||
match response {
|
||||
@@ -214,7 +211,7 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
});
|
||||
|
||||
p
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +227,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
|
||||
let (ready, p) = oneshot::oneshot();
|
||||
|
||||
res.then(move |res| {
|
||||
Box::new(res.then(move |res| {
|
||||
handle_dispatch(res, move |response| {
|
||||
match response {
|
||||
Ok(RpcConfirmationResponse::Signature(sig)) => ready.send(Ok(sig)),
|
||||
@@ -240,7 +237,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
});
|
||||
|
||||
p
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcH256, Error> {
|
||||
@@ -252,7 +249,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
|
||||
let (ready, p) = oneshot::oneshot();
|
||||
|
||||
res.then(move |res| {
|
||||
Box::new(res.then(move |res| {
|
||||
handle_dispatch(res, move |response| {
|
||||
match response {
|
||||
Ok(RpcConfirmationResponse::SendTransaction(hash)) => ready.send(Ok(hash)),
|
||||
@@ -262,7 +259,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
});
|
||||
|
||||
p
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcRichRawTransaction, Error> {
|
||||
@@ -274,7 +271,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
|
||||
let (ready, p) = oneshot::oneshot();
|
||||
|
||||
res.then(move |res| {
|
||||
Box::new(res.then(move |res| {
|
||||
handle_dispatch(res, move |response| {
|
||||
match response {
|
||||
Ok(RpcConfirmationResponse::SignTransaction(tx)) => ready.send(Ok(tx)),
|
||||
@@ -284,6 +281,6 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
});
|
||||
|
||||
p
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ use std::sync::Arc;
|
||||
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
|
||||
use futures::{future, BoxFuture, Future};
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::{BoxFuture, Error};
|
||||
use jsonrpc_core::futures::{future, Future};
|
||||
use v1::helpers::{errors, DefaultAccount};
|
||||
use v1::helpers::dispatch::{self, Dispatcher};
|
||||
use v1::helpers::accounts::unwrap_provider;
|
||||
@@ -64,12 +64,11 @@ impl<D: Dispatcher + 'static> SigningUnsafeClient<D> {
|
||||
};
|
||||
|
||||
let dis = self.dispatcher.clone();
|
||||
dispatch::from_rpc(payload, default, &dis)
|
||||
Box::new(dispatch::from_rpc(payload, default, &dis)
|
||||
.and_then(move |payload| {
|
||||
dispatch::execute(dis, accounts, payload, dispatch::SignWith::Nothing)
|
||||
})
|
||||
.map(|v| v.into_value())
|
||||
.boxed()
|
||||
.map(|v| v.into_value()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,33 +77,30 @@ impl<D: Dispatcher + 'static> EthSigning for SigningUnsafeClient<D>
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcH520, Error> {
|
||||
self.handle(RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()), address.into())
|
||||
Box::new(self.handle(RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()), address.into())
|
||||
.then(|res| match res {
|
||||
Ok(RpcConfirmationResponse::Signature(signature)) => Ok(signature),
|
||||
Err(e) => Err(e),
|
||||
e => Err(errors::internal("Unexpected result", e)),
|
||||
})
|
||||
.boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn send_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcH256, Error> {
|
||||
self.handle(RpcConfirmationPayload::SendTransaction(request), meta.dapp_id().into())
|
||||
Box::new(self.handle(RpcConfirmationPayload::SendTransaction(request), meta.dapp_id().into())
|
||||
.then(|res| match res {
|
||||
Ok(RpcConfirmationResponse::SendTransaction(hash)) => Ok(hash),
|
||||
Err(e) => Err(e),
|
||||
e => Err(errors::internal("Unexpected result", e)),
|
||||
})
|
||||
.boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn sign_transaction(&self, meta: Metadata, request: RpcTransactionRequest) -> BoxFuture<RpcRichRawTransaction, Error> {
|
||||
self.handle(RpcConfirmationPayload::SignTransaction(request), meta.dapp_id().into())
|
||||
Box::new(self.handle(RpcConfirmationPayload::SignTransaction(request), meta.dapp_id().into())
|
||||
.then(|res| match res {
|
||||
Ok(RpcConfirmationResponse::SignTransaction(tx)) => Ok(tx),
|
||||
Err(e) => Err(e),
|
||||
e => Err(errors::internal("Unexpected result", e)),
|
||||
})
|
||||
.boxed()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,27 +110,26 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningUnsafeClient<D> {
|
||||
fn compose_transaction(&self, meta: Metadata, transaction: RpcTransactionRequest) -> BoxFuture<RpcTransactionRequest, Error> {
|
||||
let accounts = try_bf!(self.account_provider());
|
||||
let default_account = accounts.dapp_default_address(meta.dapp_id().into()).ok().unwrap_or_default();
|
||||
self.dispatcher.fill_optional_fields(transaction.into(), default_account, true).map(Into::into).boxed()
|
||||
Box::new(self.dispatcher.fill_optional_fields(transaction.into(), default_account, true).map(Into::into))
|
||||
}
|
||||
|
||||
fn decrypt_message(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcBytes, Error> {
|
||||
self.handle(RpcConfirmationPayload::Decrypt((address.clone(), data).into()), address.into())
|
||||
Box::new(self.handle(RpcConfirmationPayload::Decrypt((address.clone(), data).into()), address.into())
|
||||
.then(|res| match res {
|
||||
Ok(RpcConfirmationResponse::Decrypt(data)) => Ok(data),
|
||||
Err(e) => Err(e),
|
||||
e => Err(errors::internal("Unexpected result", e)),
|
||||
})
|
||||
.boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
fn post_sign(&self, _: Metadata, _: RpcH160, _: RpcBytes) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
// We don't support this in non-signer mode.
|
||||
future::err(errors::signer_disabled()).boxed()
|
||||
Box::new(future::err(errors::signer_disabled()))
|
||||
}
|
||||
|
||||
fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
// We don't support this in non-signer mode.
|
||||
future::err((errors::signer_disabled())).boxed()
|
||||
Box::new(future::err((errors::signer_disabled())))
|
||||
}
|
||||
|
||||
fn check_request(&self, _: RpcU256) -> Result<Option<RpcConfirmationResponse>, Error> {
|
||||
|
||||
@@ -24,7 +24,6 @@ use ethcore::transaction::SignedTransaction;
|
||||
use rlp::UntrustedRlp;
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_core::futures::{self, Future, BoxFuture};
|
||||
use jsonrpc_macros::Trailing;
|
||||
use v1::Metadata;
|
||||
use v1::traits::Traces;
|
||||
@@ -83,35 +82,31 @@ impl<C, M> Traces for TracesClient<C, M> where C: MiningBlockChainClient + 'stat
|
||||
.map(LocalizedTrace::from))
|
||||
}
|
||||
|
||||
fn call(&self, meta: Self::Metadata, request: CallRequest, flags: TraceOptions, block: Trailing<BlockNumber>) -> BoxFuture<TraceResults, Error> {
|
||||
fn call(&self, meta: Self::Metadata, request: CallRequest, flags: TraceOptions, block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||
let block = block.unwrap_or_default();
|
||||
|
||||
let request = CallRequest::into(request);
|
||||
let signed = try_bf!(fake_sign::sign_call(&self.client, &self.miner, request, meta.is_dapp()));
|
||||
let signed = fake_sign::sign_call(&self.client, &self.miner, request, meta.is_dapp())?;
|
||||
|
||||
let res = self.client.call(&signed, to_call_analytics(flags), block.into())
|
||||
self.client.call(&signed, to_call_analytics(flags), block.into())
|
||||
.map(TraceResults::from)
|
||||
.map_err(errors::call);
|
||||
|
||||
futures::done(res).boxed()
|
||||
.map_err(errors::call)
|
||||
}
|
||||
|
||||
fn call_many(&self, meta: Self::Metadata, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing<BlockNumber>) -> BoxFuture<Vec<TraceResults>, Error> {
|
||||
fn call_many(&self, meta: Self::Metadata, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing<BlockNumber>) -> Result<Vec<TraceResults>, Error> {
|
||||
let block = block.unwrap_or_default();
|
||||
|
||||
let requests = try_bf!(requests.into_iter()
|
||||
let requests = requests.into_iter()
|
||||
.map(|(request, flags)| {
|
||||
let request = CallRequest::into(request);
|
||||
let signed = fake_sign::sign_call(&self.client, &self.miner, request, meta.is_dapp())?;
|
||||
Ok((signed, to_call_analytics(flags)))
|
||||
})
|
||||
.collect::<Result<Vec<_>, Error>>());
|
||||
.collect::<Result<Vec<_>, Error>>()?;
|
||||
|
||||
let res = self.client.call_many(&requests, block.into())
|
||||
self.client.call_many(&requests, block.into())
|
||||
.map(|results| results.into_iter().map(TraceResults::from).collect())
|
||||
.map_err(errors::call);
|
||||
|
||||
futures::done(res).boxed()
|
||||
.map_err(errors::call)
|
||||
}
|
||||
|
||||
fn raw_transaction(&self, raw_transaction: Bytes, flags: TraceOptions, block: Trailing<BlockNumber>) -> Result<TraceResults, Error> {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Web3 rpc implementation.
|
||||
use hash::keccak;
|
||||
use jsonrpc_core::*;
|
||||
use jsonrpc_core::Error;
|
||||
use util::version;
|
||||
use v1::traits::Web3;
|
||||
use v1::types::{H256, Bytes};
|
||||
|
||||
Reference in New Issue
Block a user