From bd9c76097d485b55ae808fee345d1d76801df1ea Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 24 Apr 2015 15:36:48 +0200 Subject: eth/downloader: removed peer td management and best peer selection --- eth/downloader/peer.go | 15 +-------------- eth/downloader/queue.go | 3 +-- 2 files changed, 2 insertions(+), 16 deletions(-) (limited to 'eth/downloader') diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go index bcb8ad43a..91977f592 100644 --- a/eth/downloader/peer.go +++ b/eth/downloader/peer.go @@ -2,7 +2,6 @@ package downloader import ( "errors" - "math/big" "sync" "github.com/ethereum/go-ethereum/common" @@ -51,16 +50,6 @@ func (p peers) getPeer(id string) *peer { return p[id] } -func (p peers) bestPeer() *peer { - var peer *peer - for _, cp := range p { - if peer == nil || cp.td.Cmp(peer.td) > 0 { - peer = cp - } - } - return peer -} - // peer represents an active peer type peer struct { state int // Peer state (working, idle) @@ -68,7 +57,6 @@ type peer struct { mu sync.RWMutex id string - td *big.Int recentHash common.Hash ignored *set.Set @@ -78,10 +66,9 @@ type peer struct { } // create a new peer -func newPeer(id string, td *big.Int, hash common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) *peer { +func newPeer(id string, hash common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) *peer { return &peer{ id: id, - td: td, recentHash: hash, getHashes: getHashes, getBlocks: getBlocks, diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index adbc2a0d0..a21a44706 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -2,7 +2,6 @@ package downloader import ( "math" - "math/big" "sync" "time" @@ -93,7 +92,7 @@ func (c *queue) has(hash common.Hash) bool { return c.hashPool.Has(hash) || c.fetchPool.Has(hash) } -func (c *queue) addBlock(id string, block *types.Block, td *big.Int) { +func (c *queue) addBlock(id string, block *types.Block) { c.mu.Lock() defer c.mu.Unlock() -- cgit