Skip to content

Commit

Permalink
run gofmt -s
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/go-bitswap@5cd913a
  • Loading branch information
web3-bot committed Jun 13, 2021
1 parent e650a28 commit 696aa9e
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 117 deletions.
44 changes: 22 additions & 22 deletions bitswap/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (

bitswap "github.com/ipfs/go-bitswap"
bssession "github.com/ipfs/go-bitswap/internal/session"
bsnet "github.com/ipfs/go-bitswap/network"
testinstance "github.com/ipfs/go-bitswap/testinstance"
tn "github.com/ipfs/go-bitswap/testnet"
bsnet "github.com/ipfs/go-bitswap/network"
cid "github.com/ipfs/go-cid"
delay "github.com/ipfs/go-ipfs-delay"
mockrouting "github.com/ipfs/go-ipfs-routing/mock"
Expand Down Expand Up @@ -53,55 +53,55 @@ type bench struct {
var benches = []bench{
// Fetch from two seed nodes that both have all 100 blocks
// - request one at a time, in series
bench{"3Nodes-AllToAll-OneAtATime", 3, 100, allToAll, oneAtATime},
{"3Nodes-AllToAll-OneAtATime", 3, 100, allToAll, oneAtATime},
// - request all 100 with a single GetBlocks() call
bench{"3Nodes-AllToAll-BigBatch", 3, 100, allToAll, batchFetchAll},
{"3Nodes-AllToAll-BigBatch", 3, 100, allToAll, batchFetchAll},

// Fetch from two seed nodes, one at a time, where:
// - node A has blocks 0 - 74
// - node B has blocks 25 - 99
bench{"3Nodes-Overlap1-OneAtATime", 3, 100, overlap1, oneAtATime},
{"3Nodes-Overlap1-OneAtATime", 3, 100, overlap1, oneAtATime},

// Fetch from two seed nodes, where:
// - node A has even blocks
// - node B has odd blocks
// - both nodes have every third block

// - request one at a time, in series
bench{"3Nodes-Overlap3-OneAtATime", 3, 100, overlap2, oneAtATime},
{"3Nodes-Overlap3-OneAtATime", 3, 100, overlap2, oneAtATime},
// - request 10 at a time, in series
bench{"3Nodes-Overlap3-BatchBy10", 3, 100, overlap2, batchFetchBy10},
{"3Nodes-Overlap3-BatchBy10", 3, 100, overlap2, batchFetchBy10},
// - request all 100 in parallel as individual GetBlock() calls
bench{"3Nodes-Overlap3-AllConcurrent", 3, 100, overlap2, fetchAllConcurrent},
{"3Nodes-Overlap3-AllConcurrent", 3, 100, overlap2, fetchAllConcurrent},
// - request all 100 with a single GetBlocks() call
bench{"3Nodes-Overlap3-BigBatch", 3, 100, overlap2, batchFetchAll},
{"3Nodes-Overlap3-BigBatch", 3, 100, overlap2, batchFetchAll},
// - request 1, then 10, then 89 blocks (similar to how IPFS would fetch a file)
bench{"3Nodes-Overlap3-UnixfsFetch", 3, 100, overlap2, unixfsFileFetch},
{"3Nodes-Overlap3-UnixfsFetch", 3, 100, overlap2, unixfsFileFetch},

// Fetch from nine seed nodes, all nodes have all blocks
// - request one at a time, in series
bench{"10Nodes-AllToAll-OneAtATime", 10, 100, allToAll, oneAtATime},
{"10Nodes-AllToAll-OneAtATime", 10, 100, allToAll, oneAtATime},
// - request 10 at a time, in series
bench{"10Nodes-AllToAll-BatchFetchBy10", 10, 100, allToAll, batchFetchBy10},
{"10Nodes-AllToAll-BatchFetchBy10", 10, 100, allToAll, batchFetchBy10},
// - request all 100 with a single GetBlocks() call
bench{"10Nodes-AllToAll-BigBatch", 10, 100, allToAll, batchFetchAll},
{"10Nodes-AllToAll-BigBatch", 10, 100, allToAll, batchFetchAll},
// - request all 100 in parallel as individual GetBlock() calls
bench{"10Nodes-AllToAll-AllConcurrent", 10, 100, allToAll, fetchAllConcurrent},
{"10Nodes-AllToAll-AllConcurrent", 10, 100, allToAll, fetchAllConcurrent},
// - request 1, then 10, then 89 blocks (similar to how IPFS would fetch a file)
bench{"10Nodes-AllToAll-UnixfsFetch", 10, 100, allToAll, unixfsFileFetch},
{"10Nodes-AllToAll-UnixfsFetch", 10, 100, allToAll, unixfsFileFetch},
// - follow a typical IPFS request pattern for 1000 blocks
bench{"10Nodes-AllToAll-UnixfsFetchLarge", 10, 1000, allToAll, unixfsFileFetchLarge},
{"10Nodes-AllToAll-UnixfsFetchLarge", 10, 1000, allToAll, unixfsFileFetchLarge},

// Fetch from nine seed nodes, blocks are distributed randomly across all nodes (no dups)
// - request one at a time, in series
bench{"10Nodes-OnePeerPerBlock-OneAtATime", 10, 100, onePeerPerBlock, oneAtATime},
{"10Nodes-OnePeerPerBlock-OneAtATime", 10, 100, onePeerPerBlock, oneAtATime},
// - request all 100 with a single GetBlocks() call
bench{"10Nodes-OnePeerPerBlock-BigBatch", 10, 100, onePeerPerBlock, batchFetchAll},
{"10Nodes-OnePeerPerBlock-BigBatch", 10, 100, onePeerPerBlock, batchFetchAll},
// - request 1, then 10, then 89 blocks (similar to how IPFS would fetch a file)
bench{"10Nodes-OnePeerPerBlock-UnixfsFetch", 10, 100, onePeerPerBlock, unixfsFileFetch},
{"10Nodes-OnePeerPerBlock-UnixfsFetch", 10, 100, onePeerPerBlock, unixfsFileFetch},

// Fetch from 199 seed nodes, all nodes have all blocks, fetch all 20 blocks with a single GetBlocks() call
bench{"200Nodes-AllToAll-BigBatch", 200, 20, allToAll, batchFetchAll},
{"200Nodes-AllToAll-BigBatch", 200, 20, allToAll, batchFetchAll},
}

func BenchmarkFixedDelay(b *testing.B) {
Expand All @@ -127,9 +127,9 @@ type mixedBench struct {
}

var mixedBenches = []mixedBench{
mixedBench{bench{"3Nodes-Overlap3-OneAtATime", 3, 10, overlap2, oneAtATime}, 1, 2},
mixedBench{bench{"3Nodes-AllToAll-OneAtATime", 3, 10, allToAll, oneAtATime}, 1, 2},
mixedBench{bench{"3Nodes-Overlap3-AllConcurrent", 3, 10, overlap2, fetchAllConcurrent}, 1, 2},
{bench{"3Nodes-Overlap3-OneAtATime", 3, 10, overlap2, oneAtATime}, 1, 2},
{bench{"3Nodes-AllToAll-OneAtATime", 3, 10, allToAll, oneAtATime}, 1, 2},
{bench{"3Nodes-Overlap3-AllConcurrent", 3, 10, overlap2, fetchAllConcurrent}, 1, 2},
// mixedBench{bench{"3Nodes-Overlap3-UnixfsFetch", 3, 100, overlap2, unixfsFileFetch}, 1, 2},
}

Expand Down
14 changes: 7 additions & 7 deletions bitswap/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ func New(parent context.Context, network bsnet.BitSwapNetwork,
sm = bssm.New(ctx, sessionFactory, sim, sessionPeerManagerFactory, bpm, pm, notif, network.Self())

bs := &Bitswap{
blockstore: bstore,
network: network,
process: px,
newBlocks: make(chan cid.Cid, HasBlockBufferSize),
provideKeys: make(chan cid.Cid, provideKeysBufferSize),
pm: pm,
pqm: pqm,
blockstore: bstore,
network: network,
process: px,
newBlocks: make(chan cid.Cid, HasBlockBufferSize),
provideKeys: make(chan cid.Cid, provideKeysBufferSize),
pm: pm,
pqm: pqm,
sm: sm,
sim: sim,
notif: notif,
Expand Down
26 changes: 13 additions & 13 deletions bitswap/internal/blockpresencemanager/blockpresencemanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,24 @@ func TestAllPeersDoNotHaveBlock(t *testing.T) {
}

testcases := []testcase{
testcase{[]peer.ID{p0}, []cid.Cid{c0}, []cid.Cid{}},
testcase{[]peer.ID{p1}, []cid.Cid{c0}, []cid.Cid{c0}},
testcase{[]peer.ID{p2}, []cid.Cid{c0}, []cid.Cid{}},
{[]peer.ID{p0}, []cid.Cid{c0}, []cid.Cid{}},
{[]peer.ID{p1}, []cid.Cid{c0}, []cid.Cid{c0}},
{[]peer.ID{p2}, []cid.Cid{c0}, []cid.Cid{}},

testcase{[]peer.ID{p0}, []cid.Cid{c1}, []cid.Cid{c1}},
testcase{[]peer.ID{p1}, []cid.Cid{c1}, []cid.Cid{}},
testcase{[]peer.ID{p2}, []cid.Cid{c1}, []cid.Cid{}},
{[]peer.ID{p0}, []cid.Cid{c1}, []cid.Cid{c1}},
{[]peer.ID{p1}, []cid.Cid{c1}, []cid.Cid{}},
{[]peer.ID{p2}, []cid.Cid{c1}, []cid.Cid{}},

testcase{[]peer.ID{p0}, []cid.Cid{c2}, []cid.Cid{c2}},
testcase{[]peer.ID{p1}, []cid.Cid{c2}, []cid.Cid{}},
testcase{[]peer.ID{p2}, []cid.Cid{c2}, []cid.Cid{c2}},
{[]peer.ID{p0}, []cid.Cid{c2}, []cid.Cid{c2}},
{[]peer.ID{p1}, []cid.Cid{c2}, []cid.Cid{}},
{[]peer.ID{p2}, []cid.Cid{c2}, []cid.Cid{c2}},

// p0 recieved DONT_HAVE for c1 & c2 (but not for c0)
testcase{[]peer.ID{p0}, []cid.Cid{c0, c1, c2}, []cid.Cid{c1, c2}},
testcase{[]peer.ID{p0, p1}, []cid.Cid{c0, c1, c2}, []cid.Cid{}},
{[]peer.ID{p0}, []cid.Cid{c0, c1, c2}, []cid.Cid{c1, c2}},
{[]peer.ID{p0, p1}, []cid.Cid{c0, c1, c2}, []cid.Cid{}},
// Both p0 and p2 received DONT_HAVE for c2
testcase{[]peer.ID{p0, p2}, []cid.Cid{c0, c1, c2}, []cid.Cid{c2}},
testcase{[]peer.ID{p0, p1, p2}, []cid.Cid{c0, c1, c2}, []cid.Cid{}},
{[]peer.ID{p0, p2}, []cid.Cid{c0, c1, c2}, []cid.Cid{c2}},
{[]peer.ID{p0, p1, p2}, []cid.Cid{c0, c1, c2}, []cid.Cid{}},
}

for i, tc := range testcases {
Expand Down
2 changes: 1 addition & 1 deletion bitswap/internal/decision/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ type Engine struct {

sendDontHaves bool

self peer.ID
self peer.ID
}

// NewEngine creates a new block sending engine for the given block store
Expand Down
Loading

0 comments on commit 696aa9e

Please sign in to comment.