]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Merge branch 'supress_webrtc_logs'
authorMatt Joiner <anacrolix@gmail.com>
Mon, 11 Apr 2022 04:53:35 +0000 (14:53 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 11 Apr 2022 04:53:35 +0000 (14:53 +1000)
cmd/torrent/download.go
request-strategy-impls.go
request-strategy/order.go
request-strategy/torrent.go

index 123b3659a483c54ee69def1d3b530e5f66abda1d..6df12216b14d7f961221da2e9090d85a71b49e05 100644 (file)
@@ -287,7 +287,7 @@ func downloadErr(flags downloadFlags) error {
        clientConfig.NoDHT = !flags.Dht
        clientConfig.Debug = flags.Debug
        clientConfig.Seed = flags.Seed
-       clientConfig.PublicIp4 = flags.PublicIP
+       clientConfig.PublicIp4 = flags.PublicIP.To4()
        clientConfig.PublicIp6 = flags.PublicIP
        clientConfig.DisablePEX = !flags.Pex
        clientConfig.DisableWebtorrent = !flags.Webtorrent
index f4c126466ba4e57ec6941f3768cb08bfb5a31a08..bf3e4083129de42bc76b2bd7c8df831987d711f5 100644 (file)
@@ -44,8 +44,15 @@ type requestStrategyTorrent struct {
        t *Torrent
 }
 
-func (r requestStrategyTorrent) Piece(i int) request_strategy.Piece {
-       return requestStrategyPiece{r.t, i}
+func (r requestStrategyTorrent) IgnorePiece(i int) bool {
+       if r.t.ignorePieceForRequests(i) {
+               return true
+       }
+       if r.t.pieceNumPendingChunks(i) == 0 {
+               return true
+       }
+
+       return false
 }
 
 func (r requestStrategyTorrent) ChunksPerPiece() uint32 {
index 130c698b9f9e6e75235ef0987fa4b68a73d762dc..09f1ff0c5863c7bf1a8abdd6d472b05ebc10be69 100644 (file)
@@ -54,7 +54,6 @@ func GetRequestablePieces(input Input, pro *PieceRequestOrder, f func(ih metainf
        pro.tree.Scan(func(_i pieceRequestOrderItem) bool {
                ih := _i.key.InfoHash
                var t Torrent = input.Torrent(ih)
-               var piece Piece = t.Piece(_i.key.Index)
                pieceLength := t.PieceLength()
                if storageLeft != nil {
                        if *storageLeft < pieceLength {
@@ -62,7 +61,7 @@ func GetRequestablePieces(input Input, pro *PieceRequestOrder, f func(ih metainf
                        }
                        *storageLeft -= pieceLength
                }
-               if !piece.Request() || piece.NumPendingChunks() == 0 {
+               if t.IgnorePiece(_i.key.Index) {
                        // TODO: Clarify exactly what is verified. Stuff that's being hashed should be
                        // considered unverified and hold up further requests.
                        return true
index 51fc1a6cc3516e86fbf1772fe68c916c9294ada6..2460f2e4df1296dbf02f93ef7d0a78ad0b671f63 100644 (file)
@@ -1,7 +1,7 @@
 package request_strategy
 
 type Torrent interface {
-       Piece(int) Piece
+       IgnorePiece(int) bool
        ChunksPerPiece() uint32
        PieceLength() int64
 }