Commit 1ae80aaf authored by Péter Szilágyi's avatar Péter Szilágyi

eth: fix #1371, double lock during block/txn known set limitation

parent 60454da6
...@@ -94,11 +94,8 @@ func (p *peer) SetTd(td *big.Int) { ...@@ -94,11 +94,8 @@ func (p *peer) SetTd(td *big.Int) {
// never be propagated to this particular peer. // never be propagated to this particular peer.
func (p *peer) MarkBlock(hash common.Hash) { func (p *peer) MarkBlock(hash common.Hash) {
// If we reached the memory allowance, drop a previously known block hash // If we reached the memory allowance, drop a previously known block hash
if p.knownBlocks.Size() >= maxKnownBlocks { for p.knownBlocks.Size() >= maxKnownBlocks {
p.knownBlocks.Each(func(item interface{}) bool { p.knownBlocks.Pop()
p.knownBlocks.Remove(item)
return p.knownBlocks.Size() >= maxKnownBlocks
})
} }
p.knownBlocks.Add(hash) p.knownBlocks.Add(hash)
} }
...@@ -107,11 +104,8 @@ func (p *peer) MarkBlock(hash common.Hash) { ...@@ -107,11 +104,8 @@ func (p *peer) MarkBlock(hash common.Hash) {
// will never be propagated to this particular peer. // will never be propagated to this particular peer.
func (p *peer) MarkTransaction(hash common.Hash) { func (p *peer) MarkTransaction(hash common.Hash) {
// If we reached the memory allowance, drop a previously known transaction hash // If we reached the memory allowance, drop a previously known transaction hash
if p.knownTxs.Size() >= maxKnownTxs { for p.knownTxs.Size() >= maxKnownTxs {
p.knownTxs.Each(func(item interface{}) bool { p.knownTxs.Pop()
p.knownTxs.Remove(item)
return p.knownTxs.Size() >= maxKnownTxs
})
} }
p.knownTxs.Add(hash) p.knownTxs.Add(hash)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment