]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Increment webseed peer piece availability
authorMatt Joiner <anacrolix@gmail.com>
Fri, 12 Nov 2021 02:41:55 +0000 (13:41 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 12 Nov 2021 02:41:55 +0000 (13:41 +1100)
webseed-peer.go
webseed/client.go

index 94adabe99350c103502190da8437c21727158fd6..f15ecf6692f82f9da0b8193b1240ed9e97b42acc 100644 (file)
@@ -36,6 +36,12 @@ func (ws *webseedPeer) String() string {
 
 func (ws *webseedPeer) onGotInfo(info *metainfo.Info) {
        ws.client.SetInfo(info)
+       // There should be probably be a callback in Client instead, so it can remove pieces at its whim
+       // too.
+       ws.client.Pieces.Iterate(func(x uint32) bool {
+               ws.peer.t.incPieceAvailability(pieceIndex(x))
+               return true
+       })
 }
 
 func (ws *webseedPeer) writeInterested(interested bool) bool {
index 4e3f7317a694698b8f629c0a62a2fe69f351d298..87090e21ed8fecc85cd4296189e28de9dc74d7e2 100644 (file)
@@ -44,7 +44,8 @@ type Client struct {
        info       *metainfo.Info
        // The pieces we can request with the Url. We're more likely to ban/block at the file-level
        // given that's how requests are mapped to webseeds, but the torrent.Client works at the piece
-       // level. We can map our file-level adjustments to the pieces here.
+       // level. We can map our file-level adjustments to the pieces here. This probably need to be
+       // private in the future, if Client ever starts removing pieces.
        Pieces roaring.Bitmap
 }