mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 02:47:48 +08:00
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: Hector Sanjuan <hector@protocol.ai>
39 lines
991 B
Go
39 lines
991 B
Go
// Package exchange defines the IPFS exchange interface
|
|
package exchange
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
|
|
|
|
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
|
)
|
|
|
|
// Interface defines the functionality of the IPFS block exchange protocol.
|
|
type Interface interface { // type Exchanger interface
|
|
Fetcher
|
|
|
|
// TODO Should callers be concerned with whether the block was made
|
|
// available on the network?
|
|
HasBlock(blocks.Block) error
|
|
|
|
IsOnline() bool
|
|
|
|
io.Closer
|
|
}
|
|
|
|
// Fetcher is an object that can be used to retrieve blocks
|
|
type Fetcher interface {
|
|
// GetBlock returns the block associated with a given key.
|
|
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
|
|
}
|