Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bithack #386

Merged
merged 90 commits into from
Dec 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
5be35a8
beginnings of a bitswap refactor
whyrusleeping Nov 19, 2014
5dece16
dont panic on empty wantlist
whyrusleeping Nov 19, 2014
cfd7d53
test(bitswap)
Nov 19, 2014
77696a4
events(bitswap) try the new event logger in the bitswap GetBlock method
Nov 19, 2014
ef83126
fix(bitswap) handle error
Nov 19, 2014
768cd36
fix(bitswap) consistent event names
Nov 19, 2014
5a4eed4
fix(log) ->f
Nov 19, 2014
5165fce
use event logger here too?
Nov 19, 2014
7239036
clarify MessageReceived contract
Nov 19, 2014
3ee7ff5
naming
Nov 19, 2014
6c2a666
constify to make it clear what _can_ and _can't_ change over time
Nov 19, 2014
e5983cb
some renaming
Nov 19, 2014
f8243c3
simplify
Nov 19, 2014
9af9ee6
misc(bitswap) renaming
Nov 19, 2014
4d14475
added a new test for a dhthell scenario that was failing
whyrusleeping Nov 19, 2014
0abc72c
move some variables into strategy
whyrusleeping Nov 19, 2014
e4b2ae3
fix tests halting
whyrusleeping Nov 19, 2014
19da057
remove buffer timing in bitswap in favor of manual batching
whyrusleeping Nov 20, 2014
297ff3d
randomize rebroadcast target
whyrusleeping Nov 20, 2014
85229be
style(bitswap/notifications) make it more obvious
Nov 19, 2014
8f82308
feat(bitswap/notifications) Subscribe to multiple keys
Nov 19, 2014
81a3ba0
tests(bitswap) share constructor between tests
Nov 20, 2014
cc92ec3
fix(merkledag) missing arg
Nov 20, 2014
b13a5a9
refactor(bitswap) move wantlist to loop receive
Nov 20, 2014
11f2856
feat(bitswap) implement GetBlocks
Nov 20, 2014
a5754a5
fix(bitswap) stop the ticker when the run loop exits
Nov 20, 2014
5babfb9
tests(bitswap) share code between the two large tests
Nov 20, 2014
99ae432
start working getBlocks up the call chain
whyrusleeping Nov 21, 2014
b1b42a5
change BatchFetch to return indices
whyrusleeping Nov 21, 2014
918c8e2
refactor(blockstore) mv under blocks/
Nov 21, 2014
eb0bde0
rename
Nov 21, 2014
04a8a61
rename exchange
Nov 21, 2014
d0304de
refactor(blockstore, blockservice) use Blockstore and offline.Exchange
Nov 21, 2014
7c2053c
fix(bitswap/loop) add to wantlist just once
Nov 21, 2014
ecf62db
feat(bitswap) find providers for all keys on wantlist
Nov 21, 2014
f6cb4ab
feat(bitswap) loop over all provided keys
Nov 21, 2014
5bd3b17
style(bitswap) name -> loop
Nov 21, 2014
4ef780a
fix(bitswap) signal termination to async'ly spawned workers
Nov 21, 2014
c7c0859
fix(exchange) allow exchange to be closed
Nov 21, 2014
0ce6071
revamp BatchFetch a bit
whyrusleeping Nov 21, 2014
59a32b1
refactor(bitswap) group the deferreds
Nov 21, 2014
ab201c1
test(bitswap) Close (but skip for now)
Nov 21, 2014
d53deeb
wire GetBlocks into blockservice
whyrusleeping Nov 21, 2014
15d4f82
some cleanup, and fix minor bug in dagreader from previous commit
whyrusleeping Nov 21, 2014
ed45099
tracking down a bug dhthell found, added asserts and better logging.
whyrusleeping Nov 21, 2014
438ffa1
feat(util) ForwardNBlocks
Nov 21, 2014
be26785
fix(dep)
Nov 21, 2014
fc820a8
tests(forward)
Nov 21, 2014
a932bfd
doc
Nov 21, 2014
9120d10
a little more correctness on the new bitswap impl
whyrusleeping Nov 21, 2014
d5e7fd6
test(notifications)
Nov 21, 2014
50b00eb
use @maybebtc's ForwardBlocks function
whyrusleeping Nov 21, 2014
1fb8033
docs(bitswap/notifications)
Nov 21, 2014
03324f7
fix(bitswap/notifications) subscribe to many
Nov 22, 2014
a5fccac
tests(bitswap/notifications) test niladic
Nov 22, 2014
b3d3b1d
refactor(bitswap) forwardN no longer needed
Nov 22, 2014
134929a
misc(bs/n) rm dead code
Nov 22, 2014
6a5bc4b
fix(bs/n) remove unnecessary variable
Nov 22, 2014
e4c9731
chore(util) remove forward
Nov 22, 2014
044db5b
hotfix(dep) duplicates TEMP DONT MERGE TO MASTER
Nov 22, 2014
e393edc
Revert "hotfix(dep) duplicates TEMP DONT MERGE TO MASTER"
Nov 22, 2014
2038234
test(bs/n) check for duplicates received
Nov 22, 2014
9bf1ba6
fix(bs/notifications) prevent duplicates
Nov 22, 2014
6d217b5
ensure sending of wantlist to friendly peers
whyrusleeping Nov 22, 2014
07bb901
add a test to blockservice to demonstate GetBlocks failure.
whyrusleeping Nov 23, 2014
aac3c6a
fix(blockservice) test
Nov 24, 2014
19de304
fix(bitswap) build-breaking compilation errors
Nov 24, 2014
fb57796
fix(bs/notifications) use SubOnceEach to provide uniqueness guarantee
Nov 24, 2014
bef75d5
fix(bitswap/testutils) vendor
Nov 24, 2014
e27de2b
fix(blockservice) respect context in GetBlocks
Nov 24, 2014
d721c44
reset test to the way it ways before
Nov 24, 2014
4cc1780
fix issues in merkledag
whyrusleeping Nov 24, 2014
d063430
add a test in merkledag to exercise GetBlocks
whyrusleeping Nov 25, 2014
7a3819a
refactor(util) move block generator
Nov 26, 2014
bb0b5f7
fix(notifications) prevent deadlock when context cancelled early
Nov 26, 2014
829eac3
fix(bitswap) pass derived context to called functions
Nov 26, 2014
1e7b7ef
refactor(bitswap) perform Publish in HasBlock
Nov 26, 2014
f0a4fda
some bitswap cleanup
whyrusleeping Nov 26, 2014
bc02b77
document bitswap more
whyrusleeping Nov 26, 2014
9835c1e
doc(bitswap) fix duplicaduplication
Nov 28, 2014
3a6b6c6
cleanup, use a workgroup over channels
whyrusleeping Dec 1, 2014
c2b497e
switch over to using sendMessage vs sendRequest
whyrusleeping Dec 1, 2014
514b26e
remove sigquit from handled signals
whyrusleeping Dec 1, 2014
e8536db
make bitswap sub-RPC's timeout (slowly for now)
whyrusleeping Dec 2, 2014
432eee6
remove unnecessary concurrency in last commit
whyrusleeping Dec 2, 2014
6552163
add readme for bitswap
whyrusleeping Dec 3, 2014
260ace7
util keys need to be pointers for loggable
whyrusleeping Dec 3, 2014
f054be9
update bitswap readme
whyrusleeping Dec 3, 2014
afa28dc
update bitswap readme
whyrusleeping Dec 4, 2014
260ac96
Update README.md
whyrusleeping Dec 4, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions blockstore/blockstore.go → blocks/blockstore/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
var ValueTypeMismatch = errors.New("The retrieved value is not a Block")

type Blockstore interface {
DeleteBlock(u.Key) error
Has(u.Key) (bool, error)
Get(u.Key) (*blocks.Block, error)
Put(*blocks.Block) error
}
Expand Down Expand Up @@ -45,3 +47,11 @@ func (bs *blockstore) Get(k u.Key) (*blocks.Block, error) {
func (bs *blockstore) Put(block *blocks.Block) error {
return bs.datastore.Put(block.Key().DsKey(), block.Data)
}

func (bs *blockstore) Has(k u.Key) (bool, error) {
return bs.datastore.Has(k.DsKey())
}

func (s *blockstore) DeleteBlock(k u.Key) error {
return s.datastore.Delete(k.DsKey())
}
File renamed without changes.
25 changes: 25 additions & 0 deletions blocks/blocksutil/block_generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package blocksutil

import "github.com/jbenet/go-ipfs/blocks"

func NewBlockGenerator() BlockGenerator {
return BlockGenerator{}
}

type BlockGenerator struct {
seq int
}

func (bg *BlockGenerator) Next() *blocks.Block {
bg.seq++
return blocks.NewBlock([]byte(string(bg.seq)))
}

func (bg *BlockGenerator) Blocks(n int) []*blocks.Block {
blocks := make([]*blocks.Block, 0)
for i := 0; i < n; i++ {
b := bg.Next()
blocks = append(blocks, b)
}
return blocks
}
54 changes: 52 additions & 2 deletions blockservice/blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ import (
"time"

"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"
dssync "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
blocks "github.com/jbenet/go-ipfs/blocks"
blockstore "github.com/jbenet/go-ipfs/blocks/blockstore"
blocksutil "github.com/jbenet/go-ipfs/blocks/blocksutil"
bitswap "github.com/jbenet/go-ipfs/exchange/bitswap"
tn "github.com/jbenet/go-ipfs/exchange/bitswap/testnet"
offline "github.com/jbenet/go-ipfs/exchange/offline"
"github.com/jbenet/go-ipfs/routing/mock"
u "github.com/jbenet/go-ipfs/util"
)

func TestBlocks(t *testing.T) {
d := ds.NewMapDatastore()
bs, err := NewBlockService(d, nil)
tsds := dssync.MutexWrap(d)
bs, err := New(blockstore.NewBlockstore(tsds), offline.Exchange())
if err != nil {
t.Error("failed to construct block service", err)
return
Expand Down Expand Up @@ -55,3 +62,46 @@ func TestBlocks(t *testing.T) {
t.Error("Block data is not equal.")
}
}

func TestGetBlocksSequential(t *testing.T) {
net := tn.VirtualNetwork()
rs := mock.VirtualRoutingServer()
sg := bitswap.NewSessionGenerator(net, rs)
bg := blocksutil.NewBlockGenerator()

instances := sg.Instances(4)
blks := bg.Blocks(50)
// TODO: verify no duplicates

var servs []*BlockService
for _, i := range instances {
bserv, err := New(i.Blockstore, i.Exchange)
if err != nil {
t.Fatal(err)
}
servs = append(servs, bserv)
}

var keys []u.Key
for _, blk := range blks {
keys = append(keys, blk.Key())
servs[0].AddBlock(blk)
}

t.Log("one instance at a time, get blocks concurrently")

for i := 1; i < len(instances); i++ {
ctx, _ := context.WithTimeout(context.TODO(), time.Second*5)
out := servs[i].GetBlocks(ctx, keys)
gotten := make(map[u.Key]*blocks.Block)
for blk := range out {
if _, ok := gotten[blk.Key()]; ok {
t.Fatal("Got duplicate block!")
}
gotten[blk.Key()] = blk
}
if len(gotten) != len(blks) {
t.Fatalf("Didnt get enough blocks back: %d/%d", len(gotten), len(blks))
}
}
}
Loading