eth/downloader: cap the hash ban set, add test for it

This commit is contained in:
Péter Szilágyi
2015-06-08 14:06:36 +03:00
parent 4b2dd44711
commit 63c6cedb14
6 changed files with 64 additions and 12 deletions

View File

@ -94,7 +94,7 @@ func (p *peer) SetIdle() {
for {
// Calculate the new download bandwidth allowance
prev := atomic.LoadInt32(&p.capacity)
next := int32(math.Max(1, math.Min(MaxBlockFetch, float64(prev)*scale)))
next := int32(math.Max(1, math.Min(float64(MaxBlockFetch), float64(prev)*scale)))
// Try to update the old value
if atomic.CompareAndSwapInt32(&p.capacity, prev, next) {