diff options
author | Martin Holst Swende <martin@swende.se> | 2018-06-11 16:03:40 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-06-11 16:03:40 +0800 |
commit | eac16f98243206bee99c3daaa8aef08695f5b69e (patch) | |
tree | b309897f09113b703e2ddd2bdd55352522cb6f6a /core | |
parent | 69c52bde3f5e48a3b74264bf4854e9768ede75b2 (diff) | |
download | dexon-eac16f98243206bee99c3daaa8aef08695f5b69e.tar dexon-eac16f98243206bee99c3daaa8aef08695f5b69e.tar.gz dexon-eac16f98243206bee99c3daaa8aef08695f5b69e.tar.bz2 dexon-eac16f98243206bee99c3daaa8aef08695f5b69e.tar.lz dexon-eac16f98243206bee99c3daaa8aef08695f5b69e.tar.xz dexon-eac16f98243206bee99c3daaa8aef08695f5b69e.tar.zst dexon-eac16f98243206bee99c3daaa8aef08695f5b69e.zip |
core: improve getBadBlocks to return full block rlp (#16902)
* core: improve getBadBlocks to return full block rlp
* core, eth, ethapi: changes to getBadBlocks formatting
* ethapi: address review concerns
Diffstat (limited to 'core')
-rw-r--r-- | core/blockchain.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index bf1bbe6cb..ea26fa034 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1392,27 +1392,21 @@ func (bc *BlockChain) update() { } } -// BadBlockArgs represents the entries in the list returned when bad blocks are queried. -type BadBlockArgs struct { - Hash common.Hash `json:"hash"` - Header *types.Header `json:"header"` -} - // BadBlocks returns a list of the last 'bad blocks' that the client has seen on the network -func (bc *BlockChain) BadBlocks() ([]BadBlockArgs, error) { - headers := make([]BadBlockArgs, 0, bc.badBlocks.Len()) +func (bc *BlockChain) BadBlocks() []*types.Block { + blocks := make([]*types.Block, 0, bc.badBlocks.Len()) for _, hash := range bc.badBlocks.Keys() { - if hdr, exist := bc.badBlocks.Peek(hash); exist { - header := hdr.(*types.Header) - headers = append(headers, BadBlockArgs{header.Hash(), header}) + if blk, exist := bc.badBlocks.Peek(hash); exist { + block := blk.(*types.Block) + blocks = append(blocks, block) } } - return headers, nil + return blocks } // addBadBlock adds a bad block to the bad-block LRU cache func (bc *BlockChain) addBadBlock(block *types.Block) { - bc.badBlocks.Add(block.Header().Hash(), block.Header()) + bc.badBlocks.Add(block.Hash(), block) } // reportBlock logs a bad block error. |