Scale readahead with unchoked connections
This commit is contained in:
parent
ce3fd07fde
commit
78caa4533b
|
@ -287,7 +287,7 @@ func (cl *Client) readRaisePiecePriorities(t *torrent, off, _len int64) {
|
|||
return
|
||||
}
|
||||
cl.raisePiecePriority(t, index, piecePriorityNext)
|
||||
for i := 0; i < 5; i++ {
|
||||
for i := 0; i < t.numConnsUnchoked()-2; i++ {
|
||||
index++
|
||||
if index >= t.NumPieces() {
|
||||
break
|
||||
|
|
|
@ -77,6 +77,15 @@ type torrent struct {
|
|||
GotMetainfo <-chan struct{}
|
||||
}
|
||||
|
||||
func (t *torrent) numConnsUnchoked() (num int) {
|
||||
for _, c := range t.Conns {
|
||||
if !c.PeerChoked {
|
||||
num++
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (t *torrent) addrActive(addr string) bool {
|
||||
if _, ok := t.HalfOpen[addr]; ok {
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue