From b60ea9a5cedd5537d001c7ba45b8a57beb04f96d Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 15 May 2025 18:05:02 +1000 Subject: [PATCH] Add acksCancels and rename _cancel --- peer-impl.go | 7 ++++--- peer.go | 3 ++- webseed-peer.go | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/peer-impl.go b/peer-impl.go index 5a348fb1..d23ad6d8 100644 --- a/peer-impl.go +++ b/peer-impl.go @@ -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 69681e92..2f4a9ea7 100644 --- 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") diff --git a/webseed-peer.go b/webseed-peer.go index 19a055a6..8804137a 100644 --- a/webseed-peer.go +++ b/webseed-peer.go @@ -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") -- 2.51.0