@@ -103,6 +103,7 @@ pub struct EthClient<C, SN: ?Sized, S: ?Sized, M, EM> where
|
||||
external_miner: Arc<EM>,
|
||||
seed_compute: Mutex<SeedHashCompute>,
|
||||
options: EthClientOptions,
|
||||
eip86_transition: u64,
|
||||
}
|
||||
|
||||
impl<C, SN: ?Sized, S: ?Sized, M, EM> EthClient<C, SN, S, M, EM> where
|
||||
@@ -131,6 +132,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> EthClient<C, SN, S, M, EM> where
|
||||
external_miner: em.clone(),
|
||||
seed_compute: Mutex::new(SeedHashCompute::new()),
|
||||
options: options,
|
||||
eip86_transition: client.eip86_transition(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +168,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> EthClient<C, SN, S, M, EM> where
|
||||
seal_fields: view.seal().into_iter().map(Into::into).collect(),
|
||||
uncles: block.uncle_hashes().into_iter().map(Into::into).collect(),
|
||||
transactions: match include_txs {
|
||||
true => BlockTransactions::Full(block.view().localized_transactions().into_iter().map(Into::into).collect()),
|
||||
true => BlockTransactions::Full(block.view().localized_transactions().into_iter().map(|t| Transaction::from_localized(t, self.eip86_transition)).collect()),
|
||||
false => BlockTransactions::Hashes(block.transaction_hashes().into_iter().map(Into::into).collect()),
|
||||
},
|
||||
extra_data: Bytes::new(view.extra_data()),
|
||||
@@ -180,7 +182,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> EthClient<C, SN, S, M, EM> where
|
||||
|
||||
fn transaction(&self, id: TransactionId) -> Result<Option<Transaction>, Error> {
|
||||
match take_weak!(self.client).transaction(id) {
|
||||
Some(t) => Ok(Some(Transaction::from(t))),
|
||||
Some(t) => Ok(Some(Transaction::from_localized(t, self.eip86_transition))),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
@@ -507,7 +509,8 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
|
||||
let hash: H256 = hash.into();
|
||||
let miner = take_weak!(self.miner);
|
||||
let client = take_weak!(self.client);
|
||||
Ok(self.transaction(TransactionId::Hash(hash))?.or_else(|| miner.transaction(client.chain_info().best_block_number, &hash).map(Into::into)))
|
||||
let block_number = client.chain_info().best_block_number;
|
||||
Ok(self.transaction(TransactionId::Hash(hash))?.or_else(|| miner.transaction(block_number, &hash).map(|t| Transaction::from_pending(t, block_number, self.eip86_transition))))
|
||||
}
|
||||
|
||||
fn transaction_by_block_hash_and_index(&self, hash: RpcH256, index: Index) -> Result<Option<Transaction>, Error> {
|
||||
|
||||
@@ -25,7 +25,7 @@ use jsonrpc_core::Error;
|
||||
use jsonrpc_macros::Trailing;
|
||||
|
||||
use light::cache::Cache as LightDataCache;
|
||||
use light::client::Client as LightClient;
|
||||
use light::client::{Client as LightClient, LightChainClient};
|
||||
use light::{cht, TransactionQueue};
|
||||
use light::on_demand::{request, OnDemand};
|
||||
|
||||
@@ -123,6 +123,7 @@ impl EthClient {
|
||||
fn rich_block(&self, id: BlockId, include_txs: bool) -> BoxFuture<Option<RichBlock>, Error> {
|
||||
let (on_demand, sync) = (self.on_demand.clone(), self.sync.clone());
|
||||
let (client, engine) = (self.client.clone(), self.client.engine().clone());
|
||||
let eip86_transition = self.client.eip86_transition();
|
||||
|
||||
// helper for filling out a rich block once we've got a block and a score.
|
||||
let fill_rich = move |block: encoded::Block, score: Option<U256>| {
|
||||
@@ -149,8 +150,8 @@ impl EthClient {
|
||||
seal_fields: header.seal().into_iter().cloned().map(Into::into).collect(),
|
||||
uncles: block.uncle_hashes().into_iter().map(Into::into).collect(),
|
||||
transactions: match include_txs {
|
||||
true => BlockTransactions::Full(block.view().localized_transactions().into_iter().map(Into::into).collect()),
|
||||
false => BlockTransactions::Hashes(block.transaction_hashes().into_iter().map(Into::into).collect()),
|
||||
true => BlockTransactions::Full(block.view().localized_transactions().into_iter().map(|t| Transaction::from_localized(t, eip86_transition)).collect()),
|
||||
_ => BlockTransactions::Hashes(block.transaction_hashes().into_iter().map(Into::into).collect()),
|
||||
},
|
||||
extra_data: Bytes::new(header.extra_data().to_vec()),
|
||||
},
|
||||
|
||||
@@ -28,6 +28,8 @@ use ethstore::random_phrase;
|
||||
use ethsync::LightSyncProvider;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
|
||||
use light::client::LightChainClient;
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_macros::Trailing;
|
||||
use v1::helpers::{errors, ipfs, SigningQueue, SignerService, NetworkSettings};
|
||||
@@ -53,11 +55,13 @@ pub struct ParityClient {
|
||||
signer: Option<Arc<SignerService>>,
|
||||
dapps_interface: Option<String>,
|
||||
dapps_port: Option<u16>,
|
||||
eip86_transition: u64,
|
||||
}
|
||||
|
||||
impl ParityClient {
|
||||
/// Creates new `ParityClient`.
|
||||
pub fn new(
|
||||
client: Arc<LightChainClient>,
|
||||
light_dispatch: Arc<LightDispatcher>,
|
||||
accounts: Arc<AccountProvider>,
|
||||
logger: Arc<RotatingLogger>,
|
||||
@@ -74,6 +78,7 @@ impl ParityClient {
|
||||
signer: signer,
|
||||
dapps_interface: dapps_interface,
|
||||
dapps_port: dapps_port,
|
||||
eip86_transition: client.eip86_transition(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +250,7 @@ impl Parity for ParityClient {
|
||||
Ok(
|
||||
txq.ready_transactions(chain_info.best_block_number, chain_info.best_block_timestamp)
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
.map(|tx| Transaction::from_pending(tx, chain_info.best_block_number, self.eip86_transition))
|
||||
.collect::<Vec<_>>()
|
||||
)
|
||||
}
|
||||
@@ -256,7 +261,7 @@ impl Parity for ParityClient {
|
||||
Ok(
|
||||
txq.future_transactions(chain_info.best_block_number, chain_info.best_block_timestamp)
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
.map(|tx| Transaction::from_pending(tx, chain_info.best_block_number, self.eip86_transition))
|
||||
.collect::<Vec<_>>()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ pub struct ParityClient<C, M, S: ?Sized, U> where
|
||||
signer: Option<Arc<SignerService>>,
|
||||
dapps_interface: Option<String>,
|
||||
dapps_port: Option<u16>,
|
||||
eip86_transition: u64,
|
||||
}
|
||||
|
||||
impl<C, M, S: ?Sized, U> ParityClient<C, M, S, U> where
|
||||
@@ -103,6 +104,7 @@ impl<C, M, S: ?Sized, U> ParityClient<C, M, S, U> where
|
||||
signer: signer,
|
||||
dapps_interface: dapps_interface,
|
||||
dapps_port: dapps_port,
|
||||
eip86_transition: client.eip86_transition(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,11 +290,13 @@ impl<C, M, S: ?Sized, U> Parity for ParityClient<C, M, S, U> where
|
||||
}
|
||||
|
||||
fn pending_transactions(&self) -> Result<Vec<Transaction>, Error> {
|
||||
Ok(take_weak!(self.miner).pending_transactions().into_iter().map(Into::into).collect::<Vec<_>>())
|
||||
let block_number = take_weak!(self.client).chain_info().best_block_number;
|
||||
Ok(take_weak!(self.miner).pending_transactions().into_iter().map(|t| Transaction::from_pending(t, block_number, self.eip86_transition)).collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
fn future_transactions(&self) -> Result<Vec<Transaction>, Error> {
|
||||
Ok(take_weak!(self.miner).future_transactions().into_iter().map(Into::into).collect::<Vec<_>>())
|
||||
let block_number = take_weak!(self.client).chain_info().best_block_number;
|
||||
Ok(take_weak!(self.miner).future_transactions().into_iter().map(|t| Transaction::from_pending(t, block_number, self.eip86_transition)).collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
fn pending_transactions_stats(&self) -> Result<BTreeMap<H256, TransactionStats>, Error> {
|
||||
@@ -305,9 +309,10 @@ impl<C, M, S: ?Sized, U> Parity for ParityClient<C, M, S, U> where
|
||||
|
||||
fn local_transactions(&self) -> Result<BTreeMap<H256, LocalTransactionStatus>, Error> {
|
||||
let transactions = take_weak!(self.miner).local_transactions();
|
||||
let block_number = take_weak!(self.client).chain_info().best_block_number;
|
||||
Ok(transactions
|
||||
.into_iter()
|
||||
.map(|(hash, status)| (hash.into(), status.into()))
|
||||
.map(|(hash, status)| (hash.into(), LocalTransactionStatus::from(status, block_number, self.eip86_transition)))
|
||||
.collect()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -39,9 +39,12 @@ pub struct ParitySetClient<C, M, U, F = fetch::Client> {
|
||||
updater: Weak<U>,
|
||||
net: Weak<ManageNetwork>,
|
||||
fetch: F,
|
||||
eip86_transition: u64,
|
||||
}
|
||||
|
||||
impl<C, M, U, F> ParitySetClient<C, M, U, F> {
|
||||
impl<C, M, U, F> ParitySetClient<C, M, U, F>
|
||||
where C: MiningBlockChainClient + 'static,
|
||||
{
|
||||
/// Creates new `ParitySetClient` with given `Fetch`.
|
||||
pub fn new(client: &Arc<C>, miner: &Arc<M>, updater: &Arc<U>, net: &Arc<ManageNetwork>, fetch: F) -> Self {
|
||||
ParitySetClient {
|
||||
@@ -50,6 +53,7 @@ impl<C, M, U, F> ParitySetClient<C, M, U, F> {
|
||||
updater: Arc::downgrade(updater),
|
||||
net: Arc::downgrade(net),
|
||||
fetch: fetch,
|
||||
eip86_transition: client.eip86_transition(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,8 +179,9 @@ impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
|
||||
fn remove_transaction(&self, hash: H256) -> Result<Option<Transaction>, Error> {
|
||||
let miner = take_weak!(self.miner);
|
||||
let client = take_weak!(self.client);
|
||||
let block_number = take_weak!(self.client).chain_info().best_block_number;
|
||||
let hash = hash.into();
|
||||
|
||||
Ok(miner.remove_pending_transaction(&*client, &hash).map(Into::into))
|
||||
Ok(miner.remove_pending_transaction(&*client, &hash).map(|t| Transaction::from_pending(t, block_number, self.eip86_transition)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user