)
pro.tree.Scan(func(item PieceRequestOrderItem) bool {
ih := item.Key.InfoHash
- var t = input.Torrent(ih)
- var piece = t.Piece(item.Key.Index)
+ t := input.Torrent(ih)
+ piece := t.Piece(item.Key.Index)
pieceLength := t.PieceLength()
// Storage limits will always apply against requestable pieces, since we need to keep the
// highest priority pieces, even if they're complete or in an undesirable state.
if t.closed.IsSet() {
return false
}
- if !t.needData() && (!t.seeding() || !t.haveAnyPieces()) {
- return false
+ if t.needData() {
+ return true
}
- return true
+ return t.seeding() && t.haveAnyPieces()
}
func (t *Torrent) wantAnyConns() bool {
- if !t.networkingEnabled.Bool() {
- return false
- }
- if t.closed.IsSet() {
- return false
- }
- if !t.needData() && (!t.seeding() || !t.haveAnyPieces()) {
+ if !t.newConnsAllowed() {
return false
}
return len(t.conns) < t.maxEstablishedConns
return false
}
if len(t.conns) < t.maxEstablishedConns {
+ // Shortcut: We can take any connection direction right now.
return true
}
numIncomingConns := len(t.conns) - t.numOutgoingConns()
return false
}
if len(t.conns) < t.maxEstablishedConns {
+ // Shortcut: We can take any connection direction right now.
return true
}
numIncomingConns := len(t.conns) - t.numOutgoingConns()