ipfs / ipfs/go-graphsync

Discussion: Support planned pausing

Open
#344 3 comments 0 reactions 2 assignees Claimed by @rvagg View on GitHub
need/triage
Dominant language
Go
Stars
103
Forks
41
PR merge metrics
No merged PRs in 30d

Description

# Goals

Right now, our pause mechanism in retrieval requires inspecting every block and telling graphsync whether you want to pause, and executing this synchronously. It is less than ideal to say the least. A better mechanism would be for the retrieval protocol to tell graphsync ahead of time when to pause. This becomes especially neccesary if we move to a mode where the payments might be happening in a different process -- and checking with them is an HTTP call (that we definitely would prefer not to make on each call)

Note that we could implement this entirely in go-data-transfer without these changes in Graphsync. see https://github.com/filecoin-project/go-data-transfer/issues/297

That said, this seems like it'd make it easier.

For now, I see this working like as follows:

Add an action for the IncomingRequestHook:

```golang
type PlannedPause struct {
PauseAfterBytesSent uint64
PauseIfComplete bool
OnPause(actualSent uint64) []graphsync.ExtensionData
}

type IncomingRequestHookActions interface {
// maintain existing actions
PlanPause(PlannedPause)
}

type UpdateRequestHookActions interface {
// maintain existing actions
PlanPause(PlannedPause)
}
```

Note that multiple hooks may create planned pauses so we may need to keep a sorted array of pauses.

Logic is after each block, check pause requests, if any are before the current pause point, call on OnPause for all that have passed, add the extensions to the response, and pause it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.