Scale readahead with unchoked connections

This commit is contained in:
Matt Joiner 2015-01-11 00:16:57 +11:00
parent ce3fd07fde
commit 78caa4533b
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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