sorting rpc using uncles
This commit is contained in:
parent
ef8dd23254
commit
95538ac42c
@ -30,6 +30,7 @@ use util::sha3::*;
|
|||||||
use util::rlp::{encode, decode, UntrustedRlp, View};
|
use util::rlp::{encode, decode, UntrustedRlp, View};
|
||||||
use ethcore::account_provider::AccountProvider;
|
use ethcore::account_provider::AccountProvider;
|
||||||
use ethcore::client::{MiningBlockChainClient, BlockID, TransactionID, UncleID};
|
use ethcore::client::{MiningBlockChainClient, BlockID, TransactionID, UncleID};
|
||||||
|
use ethcore::header::Header as BlockHeader;
|
||||||
use ethcore::block::IsBlock;
|
use ethcore::block::IsBlock;
|
||||||
use ethcore::views::*;
|
use ethcore::views::*;
|
||||||
use ethcore::ethereum::Ethash;
|
use ethcore::ethereum::Ethash;
|
||||||
@ -126,33 +127,38 @@ impl<C, S, M, EM> EthClient<C, S, M, EM> where
|
|||||||
|
|
||||||
fn uncle(&self, id: UncleID) -> Result<Value, Error> {
|
fn uncle(&self, id: UncleID) -> Result<Value, Error> {
|
||||||
let client = take_weak!(self.client);
|
let client = take_weak!(self.client);
|
||||||
match client.uncle(id).and_then(|u| client.block_total_difficulty(BlockID::Hash(u.parent_hash().clone())).map(|diff| (diff, u))) {
|
|
||||||
Some((parent_difficulty, uncle)) => {
|
let uncle: BlockHeader = match client.uncle(id) {
|
||||||
let block = Block {
|
Some(rlp) => decode(&rlp),
|
||||||
hash: OptionalValue::Value(uncle.hash()),
|
None => { return Ok(Value::Null); }
|
||||||
parent_hash: uncle.parent_hash,
|
};
|
||||||
uncles_hash: uncle.uncles_hash,
|
let parent_difficulty = match client.block_total_difficulty(BlockID::Hash(uncle.parent_hash().clone())) {
|
||||||
author: uncle.author,
|
Some(difficulty) => difficulty,
|
||||||
miner: uncle.author,
|
None => { return Ok(Value::Null); }
|
||||||
state_root: uncle.state_root,
|
};
|
||||||
transactions_root: uncle.transactions_root,
|
|
||||||
number: OptionalValue::Value(U256::from(uncle.number)),
|
let block = Block {
|
||||||
gas_used: uncle.gas_used,
|
hash: OptionalValue::Value(uncle.hash()),
|
||||||
gas_limit: uncle.gas_limit,
|
parent_hash: uncle.parent_hash,
|
||||||
logs_bloom: uncle.log_bloom,
|
uncles_hash: uncle.uncles_hash,
|
||||||
timestamp: U256::from(uncle.timestamp),
|
author: uncle.author,
|
||||||
difficulty: uncle.difficulty,
|
miner: uncle.author,
|
||||||
total_difficulty: uncle.difficulty + parent_difficulty,
|
state_root: uncle.state_root,
|
||||||
receipts_root: uncle.receipts_root,
|
transactions_root: uncle.transactions_root,
|
||||||
extra_data: Bytes::new(uncle.extra_data),
|
number: OptionalValue::Value(U256::from(uncle.number)),
|
||||||
seal_fields: uncle.seal.into_iter().map(|f| decode(&f)).map(Bytes::new).collect(),
|
gas_used: uncle.gas_used,
|
||||||
uncles: vec![],
|
gas_limit: uncle.gas_limit,
|
||||||
transactions: BlockTransactions::Hashes(vec![]),
|
logs_bloom: uncle.log_bloom,
|
||||||
};
|
timestamp: U256::from(uncle.timestamp),
|
||||||
to_value(&block)
|
difficulty: uncle.difficulty,
|
||||||
},
|
total_difficulty: uncle.difficulty + parent_difficulty,
|
||||||
None => Ok(Value::Null)
|
receipts_root: uncle.receipts_root,
|
||||||
}
|
extra_data: Bytes::new(uncle.extra_data),
|
||||||
|
seal_fields: uncle.seal.into_iter().map(|f| decode(&f)).map(Bytes::new).collect(),
|
||||||
|
uncles: vec![],
|
||||||
|
transactions: BlockTransactions::Hashes(vec![]),
|
||||||
|
};
|
||||||
|
to_value(&block)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sign_call(&self, request: CallRequest) -> Result<SignedTransaction, Error> {
|
fn sign_call(&self, request: CallRequest) -> Result<SignedTransaction, Error> {
|
||||||
|
Loading…
Reference in New Issue
Block a user