Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix uncle getter #1087

Merged
merged 2 commits into from
May 16, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ethcore/src/client/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub struct TraceId {
}

/// Uniquely identifies Uncle.
#[derive(Debug)]
pub struct UncleId (
/// Block id.
pub BlockId,
Expand Down
8 changes: 4 additions & 4 deletions rpc/src/v1/impls/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>

fn uncle(&self, id: UncleId) -> Result<Value, Error> {
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))) {
Some((difficulty, uncle)) => {
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 block = Block {
hash: OptionalValue::Value(uncle.hash()),
parent_hash: uncle.parent_hash,
Expand All @@ -138,8 +138,8 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
gas_limit: uncle.gas_limit,
logs_bloom: uncle.log_bloom,
timestamp: U256::from(uncle.timestamp),
difficulty: uncle.difficulty,
total_difficulty: difficulty,
difficulty: uncle.difficulty + parent_difficulty,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? Isn't that total_difficulty?

total_difficulty: uncle.difficulty,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be:

-                   difficulty: uncle.difficulty + parent_difficulty,
+                   difficulty: uncle.difficulty,
-                   total_difficulty: uncle.difficulty,
+                   total_difficulty: uncle.difficulty + parent_difficulty,

receipts_root: uncle.receipts_root,
extra_data: Bytes::new(uncle.extra_data),
seal_fields: uncle.seal.into_iter().map(Bytes::new).collect(),
Expand Down