forked from ETHFSx/go-ipfs-exchange-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.go
More file actions
41 lines (31 loc) · 1006 Bytes
/
interface.go
File metadata and controls
41 lines (31 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Package exchange defines the IPFS exchange interface
package exchange
import (
"context"
"io"
"github.com/libp2p/go-libp2p-core/peer"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/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
Push(context.Context, uint32, peer.ID, cid.Cid) error
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) Fetcher
}