From 89bd5ed0e52937d443c00d802dfe5f22fe7d9bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Fri, 5 Aug 2022 19:55:21 +0200 Subject: [PATCH] docs: Add proper documenation to the interface. This commit was moved from ipfs/go-ipfs-exchange-interface@7604dcd563e1eda7f15bd4bbbfbec4fad67c9ac1 --- exchange/interface.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 }