Commit e5aa2acc authored by Jeromy's avatar Jeromy

Move findproviders out of main block request path

This PR moves the addition of new blocks to our wantlist (and their
subsequent broadcast to the network) outside of the clientWorker loop.
This allows blocks to more quickly propogate to peers we are already
connected to, where before we had to wait for the previous findProviders
call in clientworker to complete before we could notify our partners of
the next blocks that we want. I then changed the naming of the
clientWorker and related variables to be a bit more appropriate to the
model. Although the clientWorker (now named providerConnector) feels a
bit awkward and should probably be changed.

fix test assumption
parent a4f12ffc
......@@ -202,6 +202,8 @@ func (bs *Bitswap) GetBlocks(ctx context.Context, keys []u.Key) (<-chan *blocks.
}
promise := bs.notifications.Subscribe(ctx, keys...)
bs.wm.WantBlocks(keys)
req := &blockRequest{
keys: keys,
ctx: ctx,
......
......@@ -134,7 +134,7 @@ func (bs *Bitswap) provideCollector(ctx context.Context) {
}
}
// TODO ensure only one active request per key
// TODO: figure out clientWorkers purpose in life
func (bs *Bitswap) clientWorker(parent context.Context) {
defer log.Info("bitswap client worker shutting down...")
......@@ -147,8 +147,6 @@ func (bs *Bitswap) clientWorker(parent context.Context) {
continue
}
bs.wm.WantBlocks(keys)
// NB: Optimization. Assumes that providers of key[0] are likely to
// be able to provide for all keys. This currently holds true in most
// every situation. Later, this assumption may not hold as true.
......
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