Skip to content

Commit

Permalink
docs: Add proper documenation to the interface.
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/go-ipfs-exchange-interface@7604dcd
  • Loading branch information
MichaelMure authored Aug 5, 2022
1 parent 1b9178f commit 89bd5ed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion exchange/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ type Interface interface { // type Exchanger interface

// Fetcher is an object that can be used to retrieve blocks
type Fetcher interface {
// GetBlock returns the block associated with a given key.
// GetBlock returns the block associated with a given cid.
GetBlock(context.Context, cid.Cid) (blocks.Block, error)
// GetBlocks returns the blocks associated with the given cids.
// If the requested blocks are not found immediately, this function should hang until
// they are found. If they can't be found later, it's also acceptable to terminate.
GetBlocks(context.Context, []cid.Cid) (<-chan blocks.Block, error)
}

// SessionExchange is an exchange.Interface which supports
// sessions.
type SessionExchange interface {
Interface
// NewSession generates a new exchange session. You should use this, rather
// that calling GetBlocks, any time you intend to do several related calls
// in a row. The exchange can leverage that to be more efficient.
NewSession(context.Context) Fetcher
}

0 comments on commit 89bd5ed

Please sign in to comment.