}
}
-// Get bytes left
+// Returns a count of bytes that are not complete in storage, and not pending being written to
+// storage. This value is from the perspective of the download manager, and may not agree with the
+// actual state in storage. If you want read data synchronously you should use a Reader. See
+// https://github.com/anacrolix/torrent/issues/828.
func (t *Torrent) BytesMissing() (n int64) {
t.cl.rLock()
n = t.bytesMissingLocked()
func (t *Torrent) maybeDropMutuallyCompletePeer(
// I'm not sure about taking peer here, not all peer implementations actually drop. Maybe that's
// okay?
- p *Peer,
+ p *PeerConn,
) {
if !t.cl.config.DropMutuallyCompletePeers {
return
if p.useful() {
return
}
- t.logger.WithDefaultLevel(log.Debug).Printf("dropping %v, which is mutually complete", p)
+ p.logger.Levelf(log.Debug, "is mutually complete; dropping")
p.drop()
}
t.piece(piece).readerCond.Broadcast()
for conn := range t.conns {
conn.have(piece)
- t.maybeDropMutuallyCompletePeer(&conn.Peer)
+ t.maybeDropMutuallyCompletePeer(conn)
}
}
}
return nil
case utHolepunch.Connect:
+ t.logger.Printf("got holepunch connect request for %v from %p", msg.AddrPort, sender)
opts := outgoingConnOpts{
peerInfo: PeerInfo{
Addr: msg.AddrPort,
}
}
-func (t *Torrent) startHolepunchRendezvous(addrPort netip.AddrPort) error {
+func (t *Torrent) trySendHolepunchRendezvous(addrPort netip.AddrPort) error {
rzsSent := 0
for pc := range t.conns {
if !pc.supportsExtension(utHolepunch.ExtensionName) {
defer cl.rUnlock()
return t.dialTimeout()
}
-
-func (t *Torrent) startHolepunchRendezvousForPeerRemoteAddr(addr PeerRemoteAddr) error {
- addrPort, err := addrPortFromPeerRemoteAddr(addr)
- if err != nil {
- return err
- }
- return t.startHolepunchRendezvous(addrPort)
-}