aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-07-01 16:12:05 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-07-01 16:12:05 +0800
commit1ae80aaf64c5acfde19fee5ee3bc4579db7ea76e (patch)
treeb46a1465be890cbbe3131a1b8de69faf98253ee4 /eth
parent60454da6507f9f391e7943e002136b8e84c32521 (diff)
downloaddexon-1ae80aaf64c5acfde19fee5ee3bc4579db7ea76e.tar
dexon-1ae80aaf64c5acfde19fee5ee3bc4579db7ea76e.tar.gz
dexon-1ae80aaf64c5acfde19fee5ee3bc4579db7ea76e.tar.bz2
dexon-1ae80aaf64c5acfde19fee5ee3bc4579db7ea76e.tar.lz
dexon-1ae80aaf64c5acfde19fee5ee3bc4579db7ea76e.tar.xz
dexon-1ae80aaf64c5acfde19fee5ee3bc4579db7ea76e.tar.zst
dexon-1ae80aaf64c5acfde19fee5ee3bc4579db7ea76e.zip
eth: fix #1371, double lock during block/txn known set limitation
Diffstat (limited to 'eth')
-rw-r--r--eth/peer.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/eth/peer.go b/eth/peer.go
index c8b8457b9..088417aab 100644
--- a/eth/peer.go
+++ b/eth/peer.go
@@ -94,11 +94,8 @@ func (p *peer) SetTd(td *big.Int) {
// never be propagated to this particular peer.
func (p *peer) MarkBlock(hash common.Hash) {
// If we reached the memory allowance, drop a previously known block hash
- if p.knownBlocks.Size() >= maxKnownBlocks {
- p.knownBlocks.Each(func(item interface{}) bool {
- p.knownBlocks.Remove(item)
- return p.knownBlocks.Size() >= maxKnownBlocks
- })
+ for p.knownBlocks.Size() >= maxKnownBlocks {
+ p.knownBlocks.Pop()
}
p.knownBlocks.Add(hash)
}
@@ -107,11 +104,8 @@ func (p *peer) MarkBlock(hash common.Hash) {
// will never be propagated to this particular peer.
func (p *peer) MarkTransaction(hash common.Hash) {
// If we reached the memory allowance, drop a previously known transaction hash
- if p.knownTxs.Size() >= maxKnownTxs {
- p.knownTxs.Each(func(item interface{}) bool {
- p.knownTxs.Remove(item)
- return p.knownTxs.Size() >= maxKnownTxs
- })
+ for p.knownTxs.Size() >= maxKnownTxs {
+ p.knownTxs.Pop()
}
p.knownTxs.Add(hash)
}