Merge pull request #1087 from ethcore/fixuncle

Fix uncle getter
This commit is contained in:
Arkadiy Paronyan 2016-05-16 14:55:11 +02:00
commit ab06c9209b
2 changed files with 4 additions and 3 deletions

View File

@ -53,6 +53,7 @@ pub struct TraceId {
} }
/// Uniquely identifies Uncle. /// Uniquely identifies Uncle.
#[derive(Debug)]
pub struct UncleId ( pub struct UncleId (
/// Block id. /// Block id.
pub BlockId, pub BlockId,

View File

@ -123,8 +123,8 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
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.hash())).map(|diff| (diff, u))) { match client.uncle(id).and_then(|u| client.block_total_difficulty(BlockId::Hash(u.parent_hash().clone())).map(|diff| (diff, u))) {
Some((difficulty, uncle)) => { Some((parent_difficulty, uncle)) => {
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,
@ -139,7 +139,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
logs_bloom: uncle.log_bloom, logs_bloom: uncle.log_bloom,
timestamp: U256::from(uncle.timestamp), timestamp: U256::from(uncle.timestamp),
difficulty: uncle.difficulty, difficulty: uncle.difficulty,
total_difficulty: difficulty, total_difficulty: uncle.difficulty + parent_difficulty,
receipts_root: uncle.receipts_root, receipts_root: uncle.receipts_root,
extra_data: Bytes::new(uncle.extra_data), extra_data: Bytes::new(uncle.extra_data),
seal_fields: uncle.seal.into_iter().map(Bytes::new).collect(), seal_fields: uncle.seal.into_iter().map(Bytes::new).collect(),