Commit 4bcfe094 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

extract constants

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 0545c4d1
...@@ -29,6 +29,7 @@ const ( ...@@ -29,6 +29,7 @@ const (
maxProvidersPerRequest = 3 maxProvidersPerRequest = 3
providerRequestTimeout = time.Second * 10 providerRequestTimeout = time.Second * 10
hasBlockTimeout = time.Second * 15 hasBlockTimeout = time.Second * 15
sizeBatchRequestChan = 32
) )
var ( var (
...@@ -59,7 +60,7 @@ func New(parent context.Context, p peer.Peer, network bsnet.BitSwapNetwork, rout ...@@ -59,7 +60,7 @@ func New(parent context.Context, p peer.Peer, network bsnet.BitSwapNetwork, rout
routing: routing, routing: routing,
sender: network, sender: network,
wantlist: wantlist.NewThreadSafe(), wantlist: wantlist.NewThreadSafe(),
batchRequests: make(chan []u.Key, 32), batchRequests: make(chan []u.Key, sizeBatchRequestChan),
} }
network.SetDelegate(bs) network.SetDelegate(bs)
go bs.clientWorker(ctx) go bs.clientWorker(ctx)
......
...@@ -13,6 +13,10 @@ import ( ...@@ -13,6 +13,10 @@ import (
var log = u.Logger("engine") var log = u.Logger("engine")
const (
sizeOutboxChan = 4
)
// Envelope contains a message for a Peer // Envelope contains a message for a Peer
type Envelope struct { type Envelope struct {
// Peer is the intended recipient // Peer is the intended recipient
...@@ -43,7 +47,7 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore) *Engine { ...@@ -43,7 +47,7 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore) *Engine {
ledgerMap: make(map[u.Key]*ledger), ledgerMap: make(map[u.Key]*ledger),
bs: bs, bs: bs,
peerRequestQueue: newTaskQueue(), peerRequestQueue: newTaskQueue(),
outbox: make(chan Envelope, 4), // TODO extract constant outbox: make(chan Envelope, sizeOutboxChan),
workSignal: make(chan struct{}), workSignal: make(chan struct{}),
} }
go e.taskWorker(ctx) go e.taskWorker(ctx)
......
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