some cleanup before CR
Jeromy committed
Dec 16, 2014 at 04:52 UTC
6389bfda6b5f7695524210ac152ac967918b8034
4 files changed
+18
-20
Godeps/Godeps.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"ImportPath": "github.com/jbenet/go-ipfs",
3
- "GoVersion": "devel +ffe33f1f1f17 Tue Nov 25 15:41:33 2014 +1100",
3
+ "GoVersion": "go1.3",
4
"Packages": [
5
"./..."
6
],
exchange/bitswap/bitswap.go
+4
-7
@@ -32,10 +32,6 @@ var providerRequestTimeout = time.Second * 10
32
var hasBlockTimeout = time.Second * 15
33
var rebroadcastDelay = time.Second * 10
34
35
-const roundTime = time.Second / 2
36
-
37
-var bandwidthPerRound = 500000
38
-
35
// New initializes a BitSwap instance that communicates over the
36
// provided BitSwapNetwork. This function registers the returned instance as
37
// the network delegate.
@@ -64,7 +60,7 @@ func New(parent context.Context, p peer.Peer, network bsnet.BitSwapNetwork, rout
60
}
61
network.SetDelegate(bs)
62
go bs.clientWorker(ctx)
67
- go bs.roundWorker(ctx)
63
+ go bs.taskWorker(ctx)
64
65
return bs
66
}
@@ -90,7 +86,8 @@ type bitswap struct {
86
batchRequests chan []u.Key
87
88
// strategy makes decisions about how to interact with partners.
93
- strategy strategy.Strategy
89
+ // TODO: strategy commented out until we have a use for it again
90
+ //strategy strategy.Strategy
91
92
ledgermanager *strategy.LedgerManager
93
@@ -234,7 +231,7 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context, wantlist *wl.Wan
231
wg.Wait()
232
}
233
237
-func (bs *bitswap) roundWorker(ctx context.Context) {
234
+func (bs *bitswap) taskWorker(ctx context.Context) {
235
for {
236
select {
237
case <-ctx.Done():
exchange/bitswap/strategy/interface.go
deleted
-12
@@ -1,12 +0,0 @@
1
-package strategy
2
-
3
-import (
4
- bstore "github.com/jbenet/go-ipfs/blocks/blockstore"
5
-)
6
-
7
-type Strategy interface {
8
- // Seed initializes the decider to a deterministic state
9
- Seed(int64)
10
-
11
- GetTasks(bandwidth int, ledgers *LedgerManager, bs bstore.Blockstore) ([]*Task, error)
12
-}
exchange/bitswap/wantlist/wantlist.go
+13
@@ -56,6 +56,19 @@ func (es entrySlice) Less(i, j int) bool { return es[i].Priority > es[j].Priorit
56
func (w *Wantlist) Entries() []*Entry {
57
w.lk.RLock()
58
defer w.lk.RUnlock()
59
+
60
+ var es entrySlice
61
+
62
+ for _, e := range w.set {
63
+ es = append(es, e)
64
+ }
65
+ sort.Sort(es)
66
+ return es
67
+}
68
+
69
+func (w *Wantlist) SortedEntries() []*Entry {
70
+ w.lk.RLock()
71
+ defer w.lk.RUnlock()
72
var es entrySlice
73
74
for _, e := range w.set {