From a7dff20e3fd0c132a840dcd393bd147ca87a3d50 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 12 Nov 2021 13:41:55 +1100 Subject: [PATCH] Increment webseed peer piece availability --- webseed-peer.go | 6 ++++++ webseed/client.go | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/webseed-peer.go b/webseed-peer.go index 94adabe9..f15ecf66 100644 --- a/webseed-peer.go +++ b/webseed-peer.go @@ -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 { diff --git a/webseed/client.go b/webseed/client.go index 4e3f7317..87090e21 100644 --- a/webseed/client.go +++ b/webseed/client.go @@ -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 } -- 2.44.0