diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-14 23:16:30 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-14 23:16:30 +0800 |
commit | 060a07cf69a2083611565e92cfa78d35c71cdb9f (patch) | |
tree | 4d499550d07ebf21d74f08dc7667213faf7621de /eth/downloader/queue.go | |
parent | 90b94e64fcdc6a2099ec5c48e41acf7f95a6b804 (diff) | |
parent | fe87feccb157b2426075523a592cabcb4c6d1cf0 (diff) | |
download | dexon-060a07cf69a2083611565e92cfa78d35c71cdb9f.tar dexon-060a07cf69a2083611565e92cfa78d35c71cdb9f.tar.gz dexon-060a07cf69a2083611565e92cfa78d35c71cdb9f.tar.bz2 dexon-060a07cf69a2083611565e92cfa78d35c71cdb9f.tar.lz dexon-060a07cf69a2083611565e92cfa78d35c71cdb9f.tar.xz dexon-060a07cf69a2083611565e92cfa78d35c71cdb9f.tar.zst dexon-060a07cf69a2083611565e92cfa78d35c71cdb9f.zip |
Merge pull request #974 from karalabe/downloader-fix-unknown-parent-attack
eth, eth/downloader: handle a potential unknown parent attack
Diffstat (limited to 'eth/downloader/queue.go')
-rw-r--r-- | eth/downloader/queue.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index 40749698c..6ad915757 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -172,17 +172,11 @@ func (q *queue) GetBlock(hash common.Hash) *types.Block { } // TakeBlocks retrieves and permanently removes a batch of blocks from the cache. -// The head parameter is required to prevent a race condition where concurrent -// takes may fail parent verifications. -func (q *queue) TakeBlocks(head *types.Block) types.Blocks { +func (q *queue) TakeBlocks() types.Blocks { q.lock.Lock() defer q.lock.Unlock() - // Short circuit if the head block's different - if len(q.blockCache) == 0 || q.blockCache[0] != head { - return nil - } - // Otherwise accumulate all available blocks + // Accumulate all available blocks var blocks types.Blocks for _, block := range q.blockCache { if block == nil { |