Skip to content

Commit

Permalink
FIXUP bitswap interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed Mar 23, 2023
1 parent 751763d commit b38c1c4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rapide/rapide.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ type ClosableBlockIterator interface {
blocks.BlockIterator
}

type ClientDrivenDownloader interface {
// Download must be asynchronous. It schedule a block to be downloaded and
// callback to be called when either it failed or succeeded.
// Clients need to callback when they have blocks or error.
// In the callback either []byte != nil and error == nil or error != nil and []byte == nil.
// When a callback for a cid is called the CID is cancel regardless of the success.
// The callback is expected to be really fast and should be called synchronously.
Download(cid.Cid, func([]byte, error))

// Cancel indicates that we are no longer intrested in a particular block.
// The callback is still allowed to be called again but that really not advised.
Cancel(cid.Cid)
}

// A Client is a collection of routers and protocols that can be used to do requests.
type Client struct {
ServerDrivenDownloaders []ServerDrivenDownloader
Expand Down

0 comments on commit b38c1c4

Please sign in to comment.