adjust naming
Jeromy committed
May 25, 2015 at 18:00 UTC
efa442ada2b0a709cf98f29d0882fdf9539a2c80
2 files changed
+8
-10
exchange/bitswap/bitswap.go
+4
-6
@@ -82,7 +82,7 @@ func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
82
notifications: notif,
83
engine: decision.NewEngine(ctx, bstore), // TODO close the engine with Close() method
84
network: network,
85
- batchRequests: make(chan *blockRequest, sizeBatchRequestChan),
85
+ findKeys: make(chan *blockRequest, sizeBatchRequestChan),
86
process: px,
87
newBlocks: make(chan *blocks.Block, HasBlockBufferSize),
88
provideKeys: make(chan u.Key),
@@ -115,10 +115,8 @@ type Bitswap struct {
115
116
notifications notifications.PubSub
117
118
- // Requests for a set of related blocks
119
- // the assumption is made that the same peer is likely to
120
- // have more than a single block in the set
121
- batchRequests chan *blockRequest
118
+ // send keys to a worker to find and connect to providers for them
119
+ findKeys chan *blockRequest
120
121
engine *decision.Engine
122
@@ -209,7 +207,7 @@ func (bs *Bitswap) GetBlocks(ctx context.Context, keys []u.Key) (<-chan *blocks.
207
ctx: ctx,
208
}
209
select {
212
- case bs.batchRequests <- req:
210
+ case bs.findKeys <- req:
211
return promise, nil
212
case <-ctx.Done():
213
return nil, ctx.Err()
exchange/bitswap/workers.go
+4
-4
@@ -31,7 +31,7 @@ func init() {
31
func (bs *Bitswap) startWorkers(px process.Process, ctx context.Context) {
32
// Start up a worker to handle block requests this node is making
33
px.Go(func(px process.Process) {
34
- bs.clientWorker(ctx)
34
+ bs.providerConnector(ctx)
35
})
36
37
// Start up workers to handle requests from other nodes for the data on this node
@@ -134,13 +134,13 @@ func (bs *Bitswap) provideCollector(ctx context.Context) {
134
}
135
}
136
137
-// TODO: figure out clientWorkers purpose in life
138
-func (bs *Bitswap) clientWorker(parent context.Context) {
137
+// connects to providers for the given keys
138
+func (bs *Bitswap) providerConnector(parent context.Context) {
139
defer log.Info("bitswap client worker shutting down...")
140
141
for {
142
select {
143
- case req := <-bs.batchRequests:
143
+ case req := <-bs.findKeys:
144
keys := req.keys
145
if len(keys) == 0 {
146
log.Warning("Received batch request for zero blocks")