aboutsummaryrefslogtreecommitdiffstats
path: root/blockpool/peers.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-20 07:00:19 +0800
committerzelig <viktor.tron@gmail.com>2015-03-20 18:41:41 +0800
commit137a9c9365dd9ec76d4a4aab7475d716457d00ae (patch)
treebbd282f06b0559c53f9fe3ae7c7beb74e0cfe592 /blockpool/peers.go
parenta9926a289dd21bcfd8e2def8f4005b43b728cb3d (diff)
downloadgo-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar
go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.gz
go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.bz2
go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.lz
go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.xz
go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.tar.zst
go-tangerine-137a9c9365dd9ec76d4a4aab7475d716457d00ae.zip
check and penalise td misreporting
- add ErrIncorrectTD - checkTD called after insertChain successful - fix tests, use blockPoolTester.tds to map block index to TD
Diffstat (limited to 'blockpool/peers.go')
-rw-r--r--blockpool/peers.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/blockpool/peers.go b/blockpool/peers.go
index b463137e3..5cc483a3b 100644
--- a/blockpool/peers.go
+++ b/blockpool/peers.go
@@ -452,8 +452,12 @@ func (self *peer) getBlockHashes() {
self.addError(ErrInvalidBlock, "%v", err)
self.bp.status.badPeers[self.id]++
} else {
+ if self.currentBlock.Td != nil {
+ if self.td.Cmp(self.currentBlock.Td) != 0 {
+ self.addError(ErrIncorrectTD, "on block %x", self.currentBlockHash)
+ }
+ }
headKey := self.parentHash.Str()
- height := self.bp.status.chain[headKey] + 1
self.bp.status.chain[self.currentBlockHash.Str()] = height
if height > self.bp.status.values.LongestChain {
self.bp.status.values.LongestChain = height
@@ -471,6 +475,7 @@ func (self *peer) getBlockHashes() {
block: self.currentBlock,
hashBy: self.id,
blockBy: self.id,
+ td: self.td,
}
self.bp.newSection([]*node{n}).activate(self)
} else {