From 2738d720955439fe3f9013d1bbc6e32c297aba2b Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 15 Sep 2014 04:26:36 -0700 Subject: [PATCH] feat(bitswap) add interface --- bitswap/interface.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bitswap/interface.go diff --git a/bitswap/interface.go b/bitswap/interface.go new file mode 100644 index 000000000..0fcff88d6 --- /dev/null +++ b/bitswap/interface.go @@ -0,0 +1,23 @@ +package bitswap + +import ( + "time" + + blocks "github.com/jbenet/go-ipfs/blocks" + 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 + // TODO(brian): rename -> Block + GetBlock(k u.Key, timeout time.Duration) (*blocks.Block, error) + + // 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? + HaveBlock(*blocks.Block) error +}