@cryptotaxi247 / kubo / commits / 4bcfe094a

extract constants

License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Dec 17, 2014 at 01:52 UTC 4bcfe094a13d8af0c4b2b0f39731eb12714c5610
2 files changed +7 -2
exchange/bitswap/bitswap.go
+2 -1
@@ -29,6 +29,7 @@ const (
29 maxProvidersPerRequest = 3
30 providerRequestTimeout = time.Second * 10
31 hasBlockTimeout = time.Second * 15
32 + sizeBatchRequestChan = 32
33 )
34
35 var (
@@ -59,7 +60,7 @@ func New(parent context.Context, p peer.Peer, network bsnet.BitSwapNetwork, rout
60 routing: routing,
61 sender: network,
62 wantlist: wantlist.NewThreadSafe(),
62 - batchRequests: make(chan []u.Key, 32),
63 + batchRequests: make(chan []u.Key, sizeBatchRequestChan),
64 }
65 network.SetDelegate(bs)
66 go bs.clientWorker(ctx)
exchange/bitswap/decision/engine.go
+5 -1
@@ -13,6 +13,10 @@ import (
13
14 var log = u.Logger("engine")
15
16 +const (
17 + sizeOutboxChan = 4
18 +)
19 +
20 // Envelope contains a message for a Peer
21 type Envelope struct {
22 // Peer is the intended recipient
@@ -43,7 +47,7 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore) *Engine {
47 ledgerMap: make(map[u.Key]*ledger),
48 bs: bs,
49 peerRequestQueue: newTaskQueue(),
46 - outbox: make(chan Envelope, 4), // TODO extract constant
50 + outbox: make(chan Envelope, sizeOutboxChan),
51 workSignal: make(chan struct{}),
52 }
53 go e.taskWorker(ctx)