@cryptotaxi247 / kubo / commits / 2738d7209

feat(bitswap) add interface

Brian Tiger Chow committed Sep 15, 2014 at 04:26 UTC 2738d720955439fe3f9013d1bbc6e32c297aba2b
1 file changed +23
bitswap/interface.go new
+23
@@ -0,0 +1,23 @@
1 +package bitswap
2 +
3 +import (
4 + "time"
5 +
6 + blocks "github.com/jbenet/go-ipfs/blocks"
7 + u "github.com/jbenet/go-ipfs/util"
8 +)
9 +
10 +type Exchange interface {
11 +
12 + // Block returns the block associated with a given key.
13 + // TODO(brian): pass a context instead of a timeout
14 + // TODO(brian): rename -> Block
15 + GetBlock(k u.Key, timeout time.Duration) (*blocks.Block, error)
16 +
17 + // HasBlock asserts the existence of this block
18 + // TODO(brian): rename -> HasBlock
19 + // TODO(brian): accept a value, not a pointer
20 + // TODO(brian): remove error return value. Should callers be concerned with
21 + // whether the block was made available on the network?
22 + HaveBlock(*blocks.Block) error
23 +}