Commit 6389bfda authored by Jeromy's avatar Jeromy Committed by Juan Batiz-Benet

some cleanup before CR

parent 2240272d
{ {
"ImportPath": "github.com/jbenet/go-ipfs", "ImportPath": "github.com/jbenet/go-ipfs",
"GoVersion": "devel +ffe33f1f1f17 Tue Nov 25 15:41:33 2014 +1100", "GoVersion": "go1.3",
"Packages": [ "Packages": [
"./..." "./..."
], ],
......
...@@ -32,10 +32,6 @@ var providerRequestTimeout = time.Second * 10 ...@@ -32,10 +32,6 @@ var providerRequestTimeout = time.Second * 10
var hasBlockTimeout = time.Second * 15 var hasBlockTimeout = time.Second * 15
var rebroadcastDelay = time.Second * 10 var rebroadcastDelay = time.Second * 10
const roundTime = time.Second / 2
var bandwidthPerRound = 500000
// New initializes a BitSwap instance that communicates over the // New initializes a BitSwap instance that communicates over the
// provided BitSwapNetwork. This function registers the returned instance as // provided BitSwapNetwork. This function registers the returned instance as
// the network delegate. // the network delegate.
...@@ -64,7 +60,7 @@ func New(parent context.Context, p peer.Peer, network bsnet.BitSwapNetwork, rout ...@@ -64,7 +60,7 @@ func New(parent context.Context, p peer.Peer, network bsnet.BitSwapNetwork, rout
} }
network.SetDelegate(bs) network.SetDelegate(bs)
go bs.clientWorker(ctx) go bs.clientWorker(ctx)
go bs.roundWorker(ctx) go bs.taskWorker(ctx)
return bs return bs
} }
...@@ -90,7 +86,8 @@ type bitswap struct { ...@@ -90,7 +86,8 @@ type bitswap struct {
batchRequests chan []u.Key batchRequests chan []u.Key
// strategy makes decisions about how to interact with partners. // strategy makes decisions about how to interact with partners.
strategy strategy.Strategy // TODO: strategy commented out until we have a use for it again
//strategy strategy.Strategy
ledgermanager *strategy.LedgerManager ledgermanager *strategy.LedgerManager
...@@ -234,7 +231,7 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context, wantlist *wl.Wan ...@@ -234,7 +231,7 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context, wantlist *wl.Wan
wg.Wait() wg.Wait()
} }
func (bs *bitswap) roundWorker(ctx context.Context) { func (bs *bitswap) taskWorker(ctx context.Context) {
for { for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
......
package strategy
import (
bstore "github.com/jbenet/go-ipfs/blocks/blockstore"
)
type Strategy interface {
// Seed initializes the decider to a deterministic state
Seed(int64)
GetTasks(bandwidth int, ledgers *LedgerManager, bs bstore.Blockstore) ([]*Task, error)
}
...@@ -56,6 +56,19 @@ func (es entrySlice) Less(i, j int) bool { return es[i].Priority > es[j].Priorit ...@@ -56,6 +56,19 @@ func (es entrySlice) Less(i, j int) bool { return es[i].Priority > es[j].Priorit
func (w *Wantlist) Entries() []*Entry { func (w *Wantlist) Entries() []*Entry {
w.lk.RLock() w.lk.RLock()
defer w.lk.RUnlock() defer w.lk.RUnlock()
var es entrySlice
for _, e := range w.set {
es = append(es, e)
}
sort.Sort(es)
return es
}
func (w *Wantlist) SortedEntries() []*Entry {
w.lk.RLock()
defer w.lk.RUnlock()
var es entrySlice var es entrySlice
for _, e := range w.set { for _, e := range w.set {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment