diff --git a/exchange/interface.go b/exchange/interface.go index 2c04628e3..3ae174d5c 100644 --- a/exchange/interface.go +++ b/exchange/interface.go @@ -21,8 +21,11 @@ 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) } @@ -30,5 +33,8 @@ type Fetcher interface { // 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 }