MCPcopy Create free account
hub / github.com/CPChain/chain / BadBlocks

Method BadBlocks

core/blockchain.go:1781–1790  ·  view source on GitHub ↗

BadBlocks returns a list of the last 'bad blocks' that the client has seen on the network

()

Source from the content-addressed store, hash-verified

1779
1780// BadBlocks returns a list of the last 'bad blocks' that the client has seen on the network
1781func (bc *BlockChain) BadBlocks() []*types.Block {
1782 blocks := make([]*types.Block, 0, bc.badBlocks.Len())
1783 for _, hash := range bc.badBlocks.Keys() {
1784 if blk, exist := bc.badBlocks.Peek(hash); exist {
1785 block := blk.(*types.Block)
1786 blocks = append(blocks, block)
1787 }
1788 }
1789 return blocks
1790}
1791
1792// addBadBlock adds a bad block to the bad-block LRU cache
1793func (bc *BlockChain) addBadBlock(block *types.Block) {

Callers 1

GetBadBlocksMethod · 0.80

Calls 3

PeekMethod · 0.80
LenMethod · 0.65
KeysMethod · 0.45

Tested by

no test coverage detected