interface.go 775 Bytes
Newer Older
Brian Tiger Chow's avatar
Brian Tiger Chow committed
1 2 3 4 5 6
package bitswap

import (
	"time"

	blocks "github.com/jbenet/go-ipfs/blocks"
7
	peer "github.com/jbenet/go-ipfs/peer"
Brian Tiger Chow's avatar
Brian Tiger Chow committed
8 9 10 11 12 13 14
	u "github.com/jbenet/go-ipfs/util"
)

type Exchange interface {

	// Block returns the block associated with a given key.
	// TODO(brian): pass a context instead of a timeout
15
	Block(k u.Key, timeout time.Duration) (*blocks.Block, error)
Brian Tiger Chow's avatar
Brian Tiger Chow committed
16 17 18 19 20 21

	// HasBlock asserts the existence of this block
	// TODO(brian): rename -> HasBlock
	// TODO(brian): accept a value, not a pointer
	// TODO(brian): remove error return value. Should callers be concerned with
	// whether the block was made available on the network?
22
	HasBlock(blocks.Block) error
Brian Tiger Chow's avatar
Brian Tiger Chow committed
23
}
24 25 26 27 28

type Directory interface {
	FindProvidersAsync(u.Key, int, time.Duration) <-chan *peer.Peer
	Provide(key u.Key) error
}