]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add acksCancels and rename _cancel
authorMatt Joiner <anacrolix@gmail.com>
Thu, 15 May 2025 08:05:02 +0000 (18:05 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 15 May 2025 08:05:02 +0000 (18:05 +1000)
peer-impl.go
peer.go
webseed-peer.go

index 5a348fb157028a0b9e9539a443b5529d37676926..d23ad6d8926dde84304e3b82f08f6081ac983ecd 100644 (file)
@@ -18,9 +18,10 @@ type legacyPeerImpl interface {
        // Actually go ahead and modify the pending requests.
        updateRequests()
 
-       // _cancel initiates cancellation of a request and returns acked if it expects the cancel to be
-       // handled by a follow-up event.
-       _cancel(RequestIndex) (acked bool)
+       // handleCancel initiates cancellation of a request and returns acked if it expects the cancel
+       // to be handled by a follow-up event.
+       handleCancel(RequestIndex)
+       acksCancels() bool
        // The final piece to actually commit to a request. Typically, this sends or begins handling the
        // request.
        _request(Request) bool
diff --git a/peer.go b/peer.go
index 69681e920b022932d81c79079a983d626361ece9..2f4a9ea7b762ef7232b521b4ef0ae05a2f0d4556 100644 (file)
--- a/peer.go
+++ b/peer.go
@@ -494,7 +494,8 @@ func (me *Peer) cancel(r RequestIndex) {
        if !me.deleteRequest(r) {
                panic("request not existing should have been guarded")
        }
-       if me._cancel(r) {
+       me.handleCancel(r)
+       if me.acksCancels() {
                // Record that we expect to get a cancel ack.
                if !me.requestState.Cancelled.CheckedAdd(r) {
                        panic("request already cancelled")
index 19a055a64e0ae48e8fa775ec255eb7431186fc1f..8804137afe7e34f24ad8b525e72e6df135ccb907 100644 (file)
@@ -30,6 +30,10 @@ type webseedPeer struct {
        lastUnhandledErr time.Time
 }
 
+func (me *webseedPeer) acksCancels() bool {
+       return false
+}
+
 func (me *webseedPeer) updateRequests() {
        //TODO implement me
        panic("implement me")