Merge pull request #3121 from poanetwork/vb-block-responnse-without-total-difficulty

Geth: handle response from eth_getblockbyhash JSON RPC method without totalDifficulty (uncle blocks)
pull/3126/head
Victor Baranov 5 years ago committed by GitHub
commit 959d19dcf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 43
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block.ex

@ -4,6 +4,7 @@
### Fixes ### Fixes
- [#3122](https://github.com/poanetwork/blockscout/pull/3122) - Exclude balance percentage calculation for burn address on accounts page - [#3122](https://github.com/poanetwork/blockscout/pull/3122) - Exclude balance percentage calculation for burn address on accounts page
- [#3121](https://github.com/poanetwork/blockscout/pull/3121) - Geth: handle response from eth_getblockbyhash JSON RPC method without totalDifficulty (uncle blocks)
- [#3119](https://github.com/poanetwork/blockscout/pull/3119), [#3120](https://github.com/poanetwork/blockscout/pull/3120) - Fix performance of Inventory tab loading for ERC-721 tokens - [#3119](https://github.com/poanetwork/blockscout/pull/3119), [#3120](https://github.com/poanetwork/blockscout/pull/3120) - Fix performance of Inventory tab loading for ERC-721 tokens
- [#3114](https://github.com/poanetwork/blockscout/pull/3114) - Fix performance of "Blocks validated" page - [#3114](https://github.com/poanetwork/blockscout/pull/3114) - Fix performance of "Blocks validated" page
- [#3112](https://github.com/poanetwork/blockscout/pull/3112) - Fix verification of contracts, compiled with nightly builds of solc compiler - [#3112](https://github.com/poanetwork/blockscout/pull/3112) - Fix verification of contracts, compiled with nightly builds of solc compiler

@ -235,6 +235,49 @@ defmodule EthereumJSONRPC.Block do
} }
end end
# Geth: a response from eth_getblockbyhash for uncle blocks is without `totalDifficulty` param
def elixir_to_params(
%{
"difficulty" => difficulty,
"extraData" => extra_data,
"gasLimit" => gas_limit,
"gasUsed" => gas_used,
"hash" => hash,
"logsBloom" => logs_bloom,
"miner" => miner_hash,
"number" => number,
"parentHash" => parent_hash,
"receiptsRoot" => receipts_root,
"sha3Uncles" => sha3_uncles,
"size" => size,
"stateRoot" => state_root,
"timestamp" => timestamp,
"transactionsRoot" => transactions_root,
"uncles" => uncles
} = elixir
) do
%{
difficulty: difficulty,
extra_data: extra_data,
gas_limit: gas_limit,
gas_used: gas_used,
hash: hash,
logs_bloom: logs_bloom,
miner_hash: miner_hash,
mix_hash: Map.get(elixir, "mixHash", "0x0"),
nonce: Map.get(elixir, "nonce", 0),
number: number,
parent_hash: parent_hash,
receipts_root: receipts_root,
sha3_uncles: sha3_uncles,
size: size,
state_root: state_root,
timestamp: timestamp,
transactions_root: transactions_root,
uncles: uncles
}
end
@doc """ @doc """
Get `t:EthereumJSONRPC.Transactions.elixir/0` from `t:elixir/0` Get `t:EthereumJSONRPC.Transactions.elixir/0` from `t:elixir/0`

Loading…
Cancel
Save