Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.

Commit 1339c17

Browse files
authored
update block format to match geth (#532)
1 parent c1df065 commit 1339c17

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

rpc/eth_api.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
abci "github.com/tendermint/tendermint/abci/types"
2222
"github.com/tendermint/tendermint/crypto/merkle"
23+
tmbytes "github.com/tendermint/tendermint/libs/bytes"
2324
"github.com/tendermint/tendermint/libs/log"
2425
"github.com/tendermint/tendermint/rpc/client"
2526
tmtypes "github.com/tendermint/tendermint/types"
@@ -621,25 +622,31 @@ func formatBlock(
621622
header tmtypes.Header, size int, gasLimit int64,
622623
gasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,
623624
) map[string]interface{} {
625+
if bytes.Equal(header.DataHash, []byte{}) {
626+
header.DataHash = tmbytes.HexBytes(common.Hash{}.Bytes())
627+
}
628+
624629
return map[string]interface{}{
625630
"number": hexutil.Uint64(header.Height),
626631
"hash": hexutil.Bytes(header.Hash()),
627632
"parentHash": hexutil.Bytes(header.LastBlockID.Hash),
628-
"nonce": nil, // PoW specific
629-
"sha3Uncles": nil, // No uncles in Tendermint
633+
"nonce": hexutil.Uint64(0), // PoW specific
634+
"sha3Uncles": common.Hash{}, // No uncles in Tendermint
630635
"logsBloom": bloom,
631636
"transactionsRoot": hexutil.Bytes(header.DataHash),
632637
"stateRoot": hexutil.Bytes(header.AppHash),
633638
"miner": common.Address{},
634-
"difficulty": nil,
635-
"totalDifficulty": nil,
639+
"mixHash": common.Hash{},
640+
"difficulty": 0,
641+
"totalDifficulty": 0,
636642
"extraData": hexutil.Uint64(0),
637643
"size": hexutil.Uint64(size),
638644
"gasLimit": hexutil.Uint64(gasLimit), // Static gas limit
639645
"gasUsed": (*hexutil.Big)(gasUsed),
640646
"timestamp": hexutil.Uint64(header.Time.Unix()),
641647
"transactions": transactions.([]common.Hash),
642648
"uncles": []string{},
649+
"receiptsRoot": common.Hash{},
643650
}
644651
}
645652

0 commit comments

Comments
 (0)