Skip to content

Commit

Permalink
Merge pull request #438 from jbenet/bitswap-rounds
Browse files Browse the repository at this point in the history
Bitswap rounds
  • Loading branch information
jbenet committed Dec 18, 2014
2 parents 911b54e + 9fafec1 commit afd6680
Show file tree
Hide file tree
Showing 28 changed files with 1,001 additions and 652 deletions.
7 changes: 6 additions & 1 deletion blocks/blockstore/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import (
"errors"

ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"

mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"

blocks "github.com/jbenet/go-ipfs/blocks"
u "github.com/jbenet/go-ipfs/util"
)

var ValueTypeMismatch = errors.New("The retrieved value is not a Block")

var ErrNotFound = errors.New("blockstore: block not found")

// Blockstore wraps a ThreadSafeDatastore
type Blockstore interface {
DeleteBlock(u.Key) error
Expand All @@ -34,6 +36,9 @@ type blockstore struct {

func (bs *blockstore) Get(k u.Key) (*blocks.Block, error) {
maybeData, err := bs.datastore.Get(k.DsKey())
if err == ds.ErrNotFound {
return nil, ErrNotFound
}
if err != nil {
return nil, err
}
Expand Down
4 changes: 1 addition & 3 deletions blockservice/blockservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"fmt"

context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"

blocks "github.com/jbenet/go-ipfs/blocks"
"github.com/jbenet/go-ipfs/blocks/blockstore"
exchange "github.com/jbenet/go-ipfs/exchange"
Expand Down Expand Up @@ -67,7 +65,7 @@ func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, er
return block, nil
// TODO be careful checking ErrNotFound. If the underlying
// implementation changes, this will break.
} else if err == ds.ErrNotFound && s.Exchange != nil {
} else if err == blockstore.ErrNotFound && s.Exchange != nil {
log.Debug("Blockservice: Searching bitswap.")
blk, err := s.Exchange.GetBlock(ctx, k)
if err != nil {
Expand Down
16 changes: 0 additions & 16 deletions epictest/addcat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ import (
const kSeed = 1

func Test100MBInstantaneous(t *testing.T) {
t.Log("a sanity check")

t.Parallel()

conf := Config{
NetworkLatency: 0,
RoutingLatency: 0,
Expand All @@ -41,43 +37,31 @@ func Test100MBInstantaneous(t *testing.T) {

func TestDegenerateSlowBlockstore(t *testing.T) {
SkipUnlessEpic(t)
t.Parallel()

conf := Config{BlockstoreLatency: 50 * time.Millisecond}

if err := AddCatPowers(conf, 128); err != nil {
t.Fatal(err)
}
}

func TestDegenerateSlowNetwork(t *testing.T) {
SkipUnlessEpic(t)
t.Parallel()

conf := Config{NetworkLatency: 400 * time.Millisecond}

if err := AddCatPowers(conf, 128); err != nil {
t.Fatal(err)
}
}

func TestDegenerateSlowRouting(t *testing.T) {
SkipUnlessEpic(t)
t.Parallel()

conf := Config{RoutingLatency: 400 * time.Millisecond}

if err := AddCatPowers(conf, 128); err != nil {
t.Fatal(err)
}
}

func Test100MBMacbookCoastToCoast(t *testing.T) {
SkipUnlessEpic(t)
t.Parallel()

conf := Config{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()

if err := AddCatBytes(RandomBytes(100*1024*1024), conf); err != nil {
t.Fatal(err)
}
Expand Down
Loading

0 comments on commit afd6680

Please sign in to comment.