sorting rpc using uncles

This commit is contained in:
NikVolf 2016-06-30 20:06:24 +03:00
parent ef8dd23254
commit 95538ac42c

View File

@ -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,8 +127,16 @@ 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) {
Some(rlp) => decode(&rlp),
None => { return Ok(Value::Null); }
};
let parent_difficulty = match client.block_total_difficulty(BlockID::Hash(uncle.parent_hash().clone())) {
Some(difficulty) => difficulty,
None => { return Ok(Value::Null); }
};
let block = Block { let block = Block {
hash: OptionalValue::Value(uncle.hash()), hash: OptionalValue::Value(uncle.hash()),
parent_hash: uncle.parent_hash, parent_hash: uncle.parent_hash,
@ -150,9 +159,6 @@ impl<C, S, M, EM> EthClient<C, S, M, EM> where
transactions: BlockTransactions::Hashes(vec![]), transactions: BlockTransactions::Hashes(vec![]),
}; };
to_value(&block) to_value(&block)
},
None => Ok(Value::Null)
}
} }
fn sign_call(&self, request: CallRequest) -> Result<SignedTransaction, Error> { fn sign_call(&self, request: CallRequest) -> Result<SignedTransaction, Error> {