Commit c4b9a06e authored by Hector Sanjuan's avatar Hector Sanjuan

Add exchange.SessionExchange interface for exchanges that support sessions.

Blockservice has an explicit dependency on bitswap so it can
call NewSession. It should rely on the exchange interfaces though, not
on specific implementations.

License: MIT
Signed-off-by: default avatarHector Sanjuan <hector@protocol.ai>
parent 51df926a
// package exchange defines the IPFS exchange interface
// Package exchange defines the IPFS exchange interface
package exchange
import (
......@@ -10,8 +10,7 @@ import (
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
)
// Any type that implements exchange.Interface may be used as an IPFS block
// exchange protocol.
// Interface defines the functionality of the IPFS block exchange protocol.
type Interface interface { // type Exchanger interface
Fetcher
......@@ -30,3 +29,10 @@ type Fetcher interface {
GetBlock(context.Context, *cid.Cid) (blocks.Block, error)
GetBlocks(context.Context, []*cid.Cid) (<-chan blocks.Block, error)
}
// SessionExchange is an exchange.Interface which supports
// sessions.
type SessionExchange interface {
Interface
NewSession(context.Context) Interface
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment