aboutsummaryrefslogtreecommitdiffstats
path: root/eth/handler.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-18 23:35:03 +0800
committerobscuren <geffobscura@gmail.com>2015-04-18 23:35:03 +0800
commit60613b57d1956275bb475a53b5085c4ead4ceb2c (patch)
tree819665229117f4dbee6a11c08bceab4d5f3e531e /eth/handler.go
parentff67fbf96448b83b778960a6c20ea8dfd854c825 (diff)
downloadgo-tangerine-60613b57d1956275bb475a53b5085c4ead4ceb2c.tar
go-tangerine-60613b57d1956275bb475a53b5085c4ead4ceb2c.tar.gz
go-tangerine-60613b57d1956275bb475a53b5085c4ead4ceb2c.tar.bz2
go-tangerine-60613b57d1956275bb475a53b5085c4ead4ceb2c.tar.lz
go-tangerine-60613b57d1956275bb475a53b5085c4ead4ceb2c.tar.xz
go-tangerine-60613b57d1956275bb475a53b5085c4ead4ceb2c.tar.zst
go-tangerine-60613b57d1956275bb475a53b5085c4ead4ceb2c.zip
downloader: make sure that hashes are only accepted from the active peer
Diffstat (limited to 'eth/handler.go')
-rw-r--r--eth/handler.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/eth/handler.go b/eth/handler.go
index f3fad68b7..3aa9815f1 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -194,7 +194,10 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
if err := msgStream.Decode(&hashes); err != nil {
break
}
- self.downloader.HashCh <- hashes
+ err := self.downloader.AddHashes(p.id, hashes)
+ if err != nil {
+ glog.V(logger.Debug).Infoln(err)
+ }
case GetBlocksMsg:
msgStream := rlp.NewStream(msg.Payload)
@@ -259,7 +262,11 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
// Make sure the block isn't already known. If this is the case simply drop
// the message and move on. If the TD is < currentTd; drop it as well. If this
// chain at some point becomes canonical, the downloader will fetch it.
- if self.chainman.HasBlock(hash) && self.chainman.Td().Cmp(request.TD) > 0 {
+ if self.chainman.HasBlock(hash) {
+ break
+ }
+ if self.chainman.Td().Cmp(request.TD) > 0 {
+ glog.V(logger.Debug).Infoln("dropped block", request.Block.Number(), "due to low TD", request.TD)
break
}