diff options
Diffstat (limited to 'blockpool/blockpool.go')
-rw-r--r-- | blockpool/blockpool.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/blockpool/blockpool.go b/blockpool/blockpool.go index a552e1b72..df3d14542 100644 --- a/blockpool/blockpool.go +++ b/blockpool/blockpool.go @@ -62,6 +62,7 @@ const ( ErrUnrequestedBlock ErrInsufficientChainInfo ErrIdleTooLong + ErrIncorrectTD ) var errorToString = map[int]string{ @@ -70,6 +71,7 @@ var errorToString = map[int]string{ ErrUnrequestedBlock: "Unrequested block", ErrInsufficientChainInfo: "Insufficient chain info", ErrIdleTooLong: "Idle too long", + ErrIncorrectTD: "Incorrect Total Difficulty", } // init initialises all your laundry @@ -373,6 +375,7 @@ func (self *BlockPool) AddBlockHashes(next func() (common.Hash, bool), peerId st block: bestpeer.currentBlock, hashBy: peerId, blockBy: peerId, + td: bestpeer.td, } // nodes is a list of nodes in one section ordered top-bottom (old to young) nodes = append(nodes, node) @@ -729,6 +732,17 @@ LOOP: } } +func (self *BlockPool) checkTD(nodes ...*node) { + for _, n := range nodes { + if n.td != nil { + plog.DebugDetailf("peer td %v =?= block td %v", n.td, n.block.Td) + if n.td.Cmp(n.block.Td) != 0 { + self.peers.peerError(n.blockBy, ErrIncorrectTD, "on block %x", n.hash) + } + } + } +} + // must run in separate go routine, otherwise // switchpeer -> activateChain -> activate deadlocks on section process select and peers.lock func (self *BlockPool) requestBlocks(attempts int, hashes []common.Hash) { |