From 3d497be9bdbb6b97c302d1c8b505ee265d677138 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Sun, 19 Apr 2015 13:31:37 +0200
Subject: [PATCH] eth: drop blocks with low TD

---
 eth/handler.go | 6 +++---
 eth/peer.go    | 6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/eth/handler.go b/eth/handler.go
index f1f462a89..780ec3931 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -36,6 +36,7 @@ pm.chainman.InsertChain(blocks)
 
 import (
 	"fmt"
+	"math/big"
 	"sync"
 
 	"github.com/ethereum/go-ethereum/common"
@@ -273,12 +274,11 @@ func (self *ProtocolManager) handleMsg(p *peer) error {
 		if self.chainman.HasBlock(hash) {
 			break
 		}
-		/* XXX unsure about this
+		/* XXX unsure about this */
 		if self.chainman.Td().Cmp(request.TD) > 0 && new(big.Int).Add(request.Block.Number(), big.NewInt(7)).Cmp(self.chainman.CurrentBlock().Number()) < 0 {
-			glog.V(logger.Debug).Infoln("dropped block", request.Block.Number(), "due to low TD", request.TD)
+			glog.V(logger.Debug).Infof("[%s] dropped block %v due to low TD %v\n", p.id, request.Block.Number(), request.TD)
 			break
 		}
-		*/
 
 		// Attempt to insert the newly received by checking if the parent exists.
 		// if the parent exists we process the block and propagate to our peers
diff --git a/eth/peer.go b/eth/peer.go
index 8cedbd85a..972880845 100644
--- a/eth/peer.go
+++ b/eth/peer.go
@@ -6,6 +6,8 @@ import (
 
 	"github.com/ethereum/go-ethereum/common"
 	"github.com/ethereum/go-ethereum/core/types"
+	"github.com/ethereum/go-ethereum/logger"
+	"github.com/ethereum/go-ethereum/logger/glog"
 	"github.com/ethereum/go-ethereum/p2p"
 	"gopkg.in/fatih/set.v0"
 )
@@ -85,12 +87,12 @@ func (p *peer) sendNewBlock(block *types.Block) error {
 }
 
 func (p *peer) requestHashes(from common.Hash) error {
-	p.Debugf("fetching hashes (%d) %x...\n", maxHashes, from[0:4])
+	glog.V(logger.Debug).Infof("[%s] fetching hashes (%d) %x...\n", p.id, maxHashes, from[:4])
 	return p2p.Send(p.rw, GetBlockHashesMsg, getBlockHashesMsgData{from, maxHashes})
 }
 
 func (p *peer) requestBlocks(hashes []common.Hash) error {
-	p.Debugf("fetching %v blocks", len(hashes))
+	glog.V(logger.Debug).Infof("[%s] fetching %v blocks\n", p.id, len(hashes))
 	return p2p.Send(p.rw, GetBlocksMsg, hashes)
 }
 
-- 
GitLab