eth/downloader: fix #1178, don't request blocks beyond the cache bounds

This commit is contained in:
Péter Szilágyi
2015-06-04 14:51:14 +03:00
parent 8610314918
commit 28c32d1b1b
3 changed files with 35 additions and 15 deletions

View File

@ -5,6 +5,7 @@ package downloader
import (
"errors"
"fmt"
"math"
"sync"
"sync/atomic"
@ -135,6 +136,15 @@ func (p *peer) Demote() {
}
}
// String implements fmt.Stringer.
func (p *peer) String() string {
return fmt.Sprintf("Peer %s [%s]", p.id,
fmt.Sprintf("reputation %3d, ", atomic.LoadInt32(&p.rep))+
fmt.Sprintf("capacity %3d, ", atomic.LoadInt32(&p.capacity))+
fmt.Sprintf("ignored %4d", p.ignored.Size()),
)
}
// peerSet represents the collection of active peer participating in the block
// download procedure.
type peerSet struct {