bitswap.go 17.4 KB
Newer Older
1
// Package bitswap implements the IPFS exchange interface with the BitSwap
Brian Tiger Chow's avatar
Brian Tiger Chow committed
2
// bilateral exchange protocol.
3 4 5
package bitswap

import (
6
	"context"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
7
	"errors"
dirkmc's avatar
dirkmc committed
8

9
	"sync"
Jeromy's avatar
Jeromy committed
10 11
	"time"

12
	delay "github.com/ipfs/go-ipfs-delay"
13

14
	deciface "github.com/ipfs/go-bitswap/decision"
15 16 17 18 19 20 21 22 23 24 25
	bsbpm "github.com/ipfs/go-bitswap/internal/blockpresencemanager"
	decision "github.com/ipfs/go-bitswap/internal/decision"
	bsgetter "github.com/ipfs/go-bitswap/internal/getter"
	bsmq "github.com/ipfs/go-bitswap/internal/messagequeue"
	notifications "github.com/ipfs/go-bitswap/internal/notifications"
	bspm "github.com/ipfs/go-bitswap/internal/peermanager"
	bspqm "github.com/ipfs/go-bitswap/internal/providerquerymanager"
	bssession "github.com/ipfs/go-bitswap/internal/session"
	bssim "github.com/ipfs/go-bitswap/internal/sessioninterestmanager"
	bssm "github.com/ipfs/go-bitswap/internal/sessionmanager"
	bsspm "github.com/ipfs/go-bitswap/internal/sessionpeermanager"
26 27
	bsmsg "github.com/ipfs/go-bitswap/message"
	bsnet "github.com/ipfs/go-bitswap/network"
Jeromy's avatar
Jeromy committed
28 29 30 31 32 33 34 35
	blocks "github.com/ipfs/go-block-format"
	cid "github.com/ipfs/go-cid"
	blockstore "github.com/ipfs/go-ipfs-blockstore"
	exchange "github.com/ipfs/go-ipfs-exchange-interface"
	logging "github.com/ipfs/go-log"
	metrics "github.com/ipfs/go-metrics-interface"
	process "github.com/jbenet/goprocess"
	procctx "github.com/jbenet/goprocess/context"
Raúl Kripalani's avatar
Raúl Kripalani committed
36
	peer "github.com/libp2p/go-libp2p-core/peer"
37 38
)

Jeromy's avatar
Jeromy committed
39
var log = logging.Logger("bitswap")
40
var sflog = log.Desugar()
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
41

42 43
var _ exchange.SessionExchange = (*Bitswap)(nil)

Brian Tiger Chow's avatar
Brian Tiger Chow committed
44
const (
45
	// these requests take at _least_ two minutes at the moment.
46 47
	provideTimeout         = time.Minute * 3
	defaultProvSearchDelay = time.Second
Jeromy's avatar
Jeromy committed
48
)
49

Jeromy's avatar
Jeromy committed
50
var (
51 52 53 54
	// HasBlockBufferSize is the buffer size of the channel for new blocks
	// that need to be provided. They should get pulled over by the
	// provideCollector even before they are actually provided.
	// TODO: Does this need to be this large givent that?
55 56
	HasBlockBufferSize    = 256
	provideKeysBufferSize = 2048
Steven Allen's avatar
Steven Allen committed
57
	provideWorkerMax      = 6
58 59 60

	// the 1<<18+15 is to observe old file chunks that are 1<<18 + 14 in size
	metricsBuckets = []float64{1 << 6, 1 << 10, 1 << 14, 1 << 18, 1<<18 + 15, 1 << 22}
Brian Tiger Chow's avatar
Brian Tiger Chow committed
61
)
Jeromy's avatar
Jeromy committed
62

63 64 65 66 67 68 69 70 71 72 73
// Option defines the functional option type that can be used to configure
// bitswap instances
type Option func(*Bitswap)

// ProvideEnabled is an option for enabling/disabling provide announcements
func ProvideEnabled(enabled bool) Option {
	return func(bs *Bitswap) {
		bs.provideEnabled = enabled
	}
}

74 75 76 77 78 79 80 81 82 83 84 85 86 87
// ProviderSearchDelay overwrites the global provider search delay
func ProviderSearchDelay(newProvSearchDelay time.Duration) Option {
	return func(bs *Bitswap) {
		bs.provSearchDelay = newProvSearchDelay
	}
}

// RebroadcastDelay overwrites the global provider rebroadcast delay
func RebroadcastDelay(newRebroadcastDelay delay.D) Option {
	return func(bs *Bitswap) {
		bs.rebroadcastDelay = newRebroadcastDelay
	}
}

88 89 90 91 92 93 94 95 96 97 98
// SetSendDontHaves indicates what to do when the engine receives a want-block
// for a block that is not in the blockstore. Either
// - Send a DONT_HAVE message
// - Simply don't respond
// This option is only used for testing.
func SetSendDontHaves(send bool) Option {
	return func(bs *Bitswap) {
		bs.engine.SetSendDontHaves(send)
	}
}

99 100 101 102 103 104 105
// Configures the engine to use the given score decision logic.
func WithScoreLedger(scoreLedger deciface.ScoreLedger) Option {
	return func(bs *Bitswap) {
		bs.engine.UseScoreLedger(scoreLedger)
	}
}

Brian Tiger Chow's avatar
Brian Tiger Chow committed
106 107
// New initializes a BitSwap instance that communicates over the provided
// BitSwapNetwork. This function registers the returned instance as the network
108
// delegate. Runs until context is cancelled or bitswap.Close is called.
Łukasz Magiera's avatar
Łukasz Magiera committed
109
func New(parent context.Context, network bsnet.BitSwapNetwork,
110
	bstore blockstore.Blockstore, options ...Option) exchange.Interface {
111

112 113
	// important to use provided parent context (since it may include important
	// loggable data). It's probably not a good idea to allow bitswap to be
114
	// coupled to the concerns of the ipfs daemon in this way.
115 116 117 118
	//
	// FIXME(btc) Now that bitswap manages itself using a process, it probably
	// shouldn't accept a context anymore. Clients should probably use Close()
	// exclusively. We should probably find another way to share logging data
119
	ctx, cancelFunc := context.WithCancel(parent)
120
	ctx = metrics.CtxSubScope(ctx, "bitswap")
121
	dupHist := metrics.NewCtx(ctx, "recv_dup_blocks_bytes", "Summary of duplicate"+
122
		" data blocks recived").Histogram(metricsBuckets)
123
	allHist := metrics.NewCtx(ctx, "recv_all_blocks_bytes", "Summary of all"+
124
		" data blocks recived").Histogram(metricsBuckets)
125

126 127 128
	sentHistogram := metrics.NewCtx(ctx, "sent_all_blocks_bytes", "Histogram of blocks sent by"+
		" this bitswap").Histogram(metricsBuckets)

129 130 131 132
	px := process.WithTeardown(func() error {
		return nil
	})

133 134
	// onDontHaveTimeout is called when a want-block is sent to a peer that
	// has an old version of Bitswap that doesn't support DONT_HAVE messages,
135
	// or when no response is received within a timeout.
Dirk McCormick's avatar
Dirk McCormick committed
136
	var sm *bssm.SessionManager
137
	onDontHaveTimeout := func(p peer.ID, dontHaves []cid.Cid) {
Dirk McCormick's avatar
Dirk McCormick committed
138 139
		// Simulate a message arriving with DONT_HAVEs
		sm.ReceiveFrom(ctx, p, nil, nil, dontHaves)
140
	}
141
	peerQueueFactory := func(ctx context.Context, p peer.ID) bspm.PeerQueue {
142
		return bsmq.New(ctx, p, network, onDontHaveTimeout)
143 144
	}

dirkmc's avatar
dirkmc committed
145 146 147
	sim := bssim.New()
	bpm := bsbpm.New()
	pm := bspm.New(ctx, peerQueueFactory, network.Self())
148 149
	pqm := bspqm.New(ctx, network)

150 151 152 153 154
	sessionFactory := func(
		sessctx context.Context,
		sessmgr bssession.SessionManager,
		id uint64,
		spm bssession.SessionPeerManager,
dirkmc's avatar
dirkmc committed
155 156 157
		sim *bssim.SessionInterestManager,
		pm bssession.PeerManager,
		bpm *bsbpm.BlockPresenceManager,
158
		notif notifications.PubSub,
159
		provSearchDelay time.Duration,
dirkmc's avatar
dirkmc committed
160 161
		rebroadcastDelay delay.D,
		self peer.ID) bssm.Session {
162
		return bssession.New(sessctx, sessmgr, id, spm, pqm, sim, pm, bpm, notif, provSearchDelay, rebroadcastDelay, self)
163
	}
dirkmc's avatar
dirkmc committed
164
	sessionPeerManagerFactory := func(ctx context.Context, id uint64) bssession.SessionPeerManager {
165
		return bsspm.New(id, network.ConnectionManager())
166
	}
167
	notif := notifications.New()
Dirk McCormick's avatar
Dirk McCormick committed
168
	sm = bssm.New(ctx, sessionFactory, sim, sessionPeerManagerFactory, bpm, pm, notif, network.Self())
dirkmc's avatar
dirkmc committed
169
	engine := decision.NewEngine(ctx, bstore, network.ConnectionManager(), network.Self())
170

171
	bs := &Bitswap{
172
		blockstore:       bstore,
173
		engine:           engine,
174 175 176 177
		network:          network,
		process:          px,
		newBlocks:        make(chan cid.Cid, HasBlockBufferSize),
		provideKeys:      make(chan cid.Cid, provideKeysBufferSize),
dirkmc's avatar
dirkmc committed
178
		pm:               pm,
179
		pqm:              pqm,
dirkmc's avatar
dirkmc committed
180 181
		sm:               sm,
		sim:              sim,
182
		notif:            notif,
183 184 185 186 187 188 189
		counters:         new(counters),
		dupMetric:        dupHist,
		allMetric:        allHist,
		sentHistogram:    sentHistogram,
		provideEnabled:   true,
		provSearchDelay:  defaultProvSearchDelay,
		rebroadcastDelay: delay.Fixed(time.Minute),
190 191 192 193 194
	}

	// apply functional options before starting and running bitswap
	for _, option := range options {
		option(bs)
195
	}
196

197
	bs.pqm.Startup()
Brian Tiger Chow's avatar
Brian Tiger Chow committed
198
	network.SetDelegate(bs)
199

200
	// Start up bitswaps async worker routines
201
	bs.startWorkers(ctx, px)
202
	engine.StartWorkers(ctx, px)
203 204 205 206 207

	// bind the context and process.
	// do it over here to avoid closing before all setup is done.
	go func() {
		<-px.Closing() // process closes first
208
		sm.Shutdown()
209
		cancelFunc()
210
		notif.Shutdown()
211 212 213
	}()
	procctx.CloseAfterContext(px, ctx) // parent cancelled first

214 215 216
	return bs
}

217 218
// Bitswap instances implement the bitswap protocol.
type Bitswap struct {
dirkmc's avatar
dirkmc committed
219 220
	pm *bspm.PeerManager

221 222 223
	// the provider query manager manages requests to find providers
	pqm *bspqm.ProviderQueryManager

224 225
	// the engine is the bit of logic that decides who to send which blocks to
	engine *decision.Engine
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
226

227 228
	// network delivers messages on behalf of the session
	network bsnet.BitSwapNetwork
229 230 231 232 233

	// blockstore is the local database
	// NB: ensure threadsafety
	blockstore blockstore.Blockstore

234 235 236
	// manages channels of outgoing blocks for sessions
	notif notifications.PubSub

237 238 239
	// newBlocks is a channel for newly added blocks to be provided to the
	// network.  blocks pushed down this channel get buffered and fed to the
	// provideKeys channel later on to avoid too much network activity
240
	newBlocks chan cid.Cid
241
	// provideKeys directly feeds provide workers
242
	provideKeys chan cid.Cid
243

244 245 246
	process process.Process

	// Counters for various statistics
247 248
	counterLk sync.Mutex
	counters  *counters
249 250

	// Metrics interface metrics
251 252 253
	dupMetric     metrics.Histogram
	allMetric     metrics.Histogram
	sentHistogram metrics.Histogram
Jeromy's avatar
Jeromy committed
254

Tomasz Zdybał's avatar
Tomasz Zdybał committed
255 256 257
	// External statistics interface
	wiretap WireTap

dirkmc's avatar
dirkmc committed
258
	// the SessionManager routes requests to interested sessions
259
	sm *bssm.SessionManager
260

dirkmc's avatar
dirkmc committed
261 262 263 264
	// the SessionInterestManager keeps track of which sessions are interested
	// in which CIDs
	sim *bssim.SessionInterestManager

265 266
	// whether or not to make provide announcements
	provideEnabled bool
267 268 269 270 271 272

	// how long to wait before looking for providers in a session
	provSearchDelay time.Duration

	// how often to rebroadcast providing requests to find more optimized providers
	rebroadcastDelay delay.D
273 274
}

275 276 277 278 279 280 281 282 283 284
type counters struct {
	blocksRecvd    uint64
	dupBlocksRecvd uint64
	dupDataRecvd   uint64
	blocksSent     uint64
	dataSent       uint64
	dataRecvd      uint64
	messagesRecvd  uint64
}

285
// GetBlock attempts to retrieve a particular block from peers within the
286
// deadline enforced by the context.
287
func (bs *Bitswap) GetBlock(parent context.Context, k cid.Cid) (blocks.Block, error) {
288
	return bsgetter.SyncGetBlock(parent, k, bs.GetBlocks)
289 290
}

291 292
// WantlistForPeer returns the currently understood list of blocks requested by a
// given peer.
293 294
func (bs *Bitswap) WantlistForPeer(p peer.ID) []cid.Cid {
	var out []cid.Cid
295
	for _, e := range bs.engine.WantlistForPeer(p) {
296
		out = append(out, e.Cid)
297 298 299 300
	}
	return out
}

301 302
// LedgerForPeer returns aggregated data about blocks swapped and communication
// with a given peer.
303 304 305 306
func (bs *Bitswap) LedgerForPeer(p peer.ID) *decision.Receipt {
	return bs.engine.LedgerForPeer(p)
}

307 308 309 310 311 312 313
// GetBlocks returns a channel where the caller may receive blocks that
// correspond to the provided |keys|. Returns an error if BitSwap is unable to
// begin this request within the deadline enforced by the context.
//
// NB: Your request remains open until the context expires. To conserve
// resources, provide a context with a reasonably short deadline (ie. not one
// that lasts throughout the lifetime of the server)
314
func (bs *Bitswap) GetBlocks(ctx context.Context, keys []cid.Cid) (<-chan blocks.Block, error) {
315
	session := bs.sm.NewSession(ctx, bs.provSearchDelay, bs.rebroadcastDelay)
316
	return session.GetBlocks(ctx, keys)
Jeromy's avatar
Jeromy committed
317 318
}

Łukasz Magiera's avatar
Łukasz Magiera committed
319
// HasBlock announces the existence of a block to this bitswap service. The
320
// service will potentially notify its peers.
321
func (bs *Bitswap) HasBlock(blk blocks.Block) error {
dirkmc's avatar
dirkmc committed
322
	return bs.receiveBlocksFrom(context.Background(), "", []blocks.Block{blk}, nil, nil)
323 324 325 326 327 328
}

// TODO: Some of this stuff really only needs to be done when adding a block
// from the user, not when receiving it from the network.
// In case you run `git blame` on this comment, I'll save you some time: ask
// @whyrusleeping, I don't know the answers you seek.
dirkmc's avatar
dirkmc committed
329
func (bs *Bitswap) receiveBlocksFrom(ctx context.Context, from peer.ID, blks []blocks.Block, haves []cid.Cid, dontHaves []cid.Cid) error {
330 331 332 333 334
	select {
	case <-bs.process.Closing():
		return errors.New("bitswap is closed")
	default:
	}
335

336 337 338 339
	wanted := blks

	// If blocks came from the network
	if from != "" {
dirkmc's avatar
dirkmc committed
340 341 342 343
		var notWanted []blocks.Block
		wanted, notWanted = bs.sim.SplitWantedUnwanted(blks)
		for _, b := range notWanted {
			log.Debugf("[recv] block not in wantlist; cid=%s, peer=%s", b.Cid(), from)
344 345 346 347
		}
	}

	// Put wanted blocks into blockstore
dirkmc's avatar
dirkmc committed
348 349 350 351 352 353
	if len(wanted) > 0 {
		err := bs.blockstore.PutMany(wanted)
		if err != nil {
			log.Errorf("Error writing %d blocks to datastore: %s", len(wanted), err)
			return err
		}
354
	}
355

356 357 358 359 360
	// NOTE: There exists the possiblity for a race condition here.  If a user
	// creates a node, then adds it to the dagservice while another goroutine
	// is waiting on a GetBlock for that object, they will receive a reference
	// to the same node. We should address this soon, but i'm not going to do
	// it now as it requires more thought and isnt causing immediate problems.
Jeromy's avatar
Jeromy committed
361

362 363 364 365 366
	allKs := make([]cid.Cid, 0, len(blks))
	for _, b := range blks {
		allKs = append(allKs, b.Cid())
	}

367 368 369 370 371 372 373
	// If the message came from the network
	if from != "" {
		// Inform the PeerManager so that we can calculate per-peer latency
		combined := make([]cid.Cid, 0, len(allKs)+len(haves)+len(dontHaves))
		combined = append(combined, allKs...)
		combined = append(combined, haves...)
		combined = append(combined, dontHaves...)
Dirk McCormick's avatar
Dirk McCormick committed
374
		bs.pm.ResponseReceived(from, combined)
375 376
	}

377
	// Send all block keys (including duplicates) to any sessions that want them.
378
	// (The duplicates are needed by sessions for accounting purposes)
Dirk McCormick's avatar
Dirk McCormick committed
379
	bs.sm.ReceiveFrom(ctx, from, allKs, haves, dontHaves)
380

dirkmc's avatar
dirkmc committed
381 382
	// Send wanted blocks to decision engine
	bs.engine.ReceiveFrom(from, wanted, haves)
383

384
	// Publish the block to any Bitswap clients that had requested blocks.
dirkmc's avatar
dirkmc committed
385
	// (the sessions use this pubsub mechanism to inform clients of incoming
386 387 388 389 390
	// blocks)
	for _, b := range wanted {
		bs.notif.Publish(b)
	}

391
	// If the reprovider is enabled, send wanted blocks to reprovider
392
	if bs.provideEnabled {
dirkmc's avatar
dirkmc committed
393
		for _, blk := range wanted {
394
			select {
dirkmc's avatar
dirkmc committed
395
			case bs.newBlocks <- blk.Cid():
396 397 398 399
				// send block off to be reprovided
			case <-bs.process.Closing():
				return bs.process.Close()
			}
400
		}
401
	}
402

403 404
	if from != "" {
		for _, b := range wanted {
405
			log.Debugw("Bitswap.GetBlockRequest.End", "cid", b.Cid())
406 407 408
		}
	}

409
	return nil
410 411
}

412 413
// ReceiveMessage is called by the network interface when a new message is
// received.
414
func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg.BitSwapMessage) {
Steven Allen's avatar
Steven Allen committed
415 416 417
	bs.counterLk.Lock()
	bs.counters.messagesRecvd++
	bs.counterLk.Unlock()
Jeromy's avatar
Jeromy committed
418

Jeromy's avatar
Jeromy committed
419 420
	// This call records changes to wantlists, blocks received,
	// and number of bytes transfered.
421
	bs.engine.MessageReceived(ctx, p, incoming)
Jeromy's avatar
Jeromy committed
422 423
	// TODO: this is bad, and could be easily abused.
	// Should only track *useful* messages in ledger
424

Tomasz Zdybał's avatar
Tomasz Zdybał committed
425 426 427 428
	if bs.wiretap != nil {
		bs.wiretap.MessageReceived(p, incoming)
	}

429 430
	iblocks := incoming.Blocks()

dirkmc's avatar
dirkmc committed
431 432 433 434 435
	if len(iblocks) > 0 {
		bs.updateReceiveCounters(iblocks)
		for _, b := range iblocks {
			log.Debugf("[recv] block; cid=%s, peer=%s", b.Cid(), p)
		}
436
	}
437

dirkmc's avatar
dirkmc committed
438 439 440 441 442 443
	haves := incoming.Haves()
	dontHaves := incoming.DontHaves()
	if len(iblocks) > 0 || len(haves) > 0 || len(dontHaves) > 0 {
		// Process blocks
		err := bs.receiveBlocksFrom(ctx, p, iblocks, haves, dontHaves)
		if err != nil {
444
			log.Warnf("ReceiveMessage recvBlockFrom error: %s", err)
dirkmc's avatar
dirkmc committed
445 446
			return
		}
447
	}
448 449 450 451 452 453 454
}

func (bs *Bitswap) updateReceiveCounters(blocks []blocks.Block) {
	// Check which blocks are in the datastore
	// (Note: any errors from the blockstore are simply logged out in
	// blockstoreHas())
	blocksHas := bs.blockstoreHas(blocks)
455

456 457 458
	bs.counterLk.Lock()
	defer bs.counterLk.Unlock()

459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
	// Do some accounting for each block
	for i, b := range blocks {
		has := blocksHas[i]

		blkLen := len(b.RawData())
		bs.allMetric.Observe(float64(blkLen))
		if has {
			bs.dupMetric.Observe(float64(blkLen))
		}

		c := bs.counters

		c.blocksRecvd++
		c.dataRecvd += uint64(blkLen)
		if has {
			c.dupBlocksRecvd++
			c.dupDataRecvd += uint64(blkLen)
		}
477 478 479
	}
}

480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
func (bs *Bitswap) blockstoreHas(blks []blocks.Block) []bool {
	res := make([]bool, len(blks))

	wg := sync.WaitGroup{}
	for i, block := range blks {
		wg.Add(1)
		go func(i int, b blocks.Block) {
			defer wg.Done()

			has, err := bs.blockstore.Has(b.Cid())
			if err != nil {
				log.Infof("blockstore.Has error: %s", err)
				has = false
			}

			res[i] = has
		}(i, block)
	}
	wg.Wait()

	return res
}

503 504
// PeerConnected is called by the network interface
// when a peer initiates a new connection to bitswap.
505
func (bs *Bitswap) PeerConnected(p peer.ID) {
Dirk McCormick's avatar
Dirk McCormick committed
506
	bs.pm.Connected(p)
507
	bs.engine.PeerConnected(p)
508 509
}

510 511
// PeerDisconnected is called by the network interface when a peer
// closes a connection
512
func (bs *Bitswap) PeerDisconnected(p peer.ID) {
Dirk McCormick's avatar
Dirk McCormick committed
513
	bs.pm.Disconnected(p)
514
	bs.engine.PeerDisconnected(p)
515 516
}

517 518
// ReceiveError is called by the network interface when an error happens
// at the network layer. Currently just logs error.
519
func (bs *Bitswap) ReceiveError(err error) {
520
	log.Infof("Bitswap ReceiveError: %s", err)
521 522
	// TODO log the network error
	// TODO bubble the network error up to the parent context/error logger
523 524
}

525
// Close is called to shutdown Bitswap
526
func (bs *Bitswap) Close() error {
527
	return bs.process.Close()
528
}
529

530 531
// GetWantlist returns the current local wantlist (both want-blocks and
// want-haves).
532
func (bs *Bitswap) GetWantlist() []cid.Cid {
dirkmc's avatar
dirkmc committed
533 534 535
	return bs.pm.CurrentWants()
}

536 537 538 539 540
// GetWantBlocks returns the current list of want-blocks.
func (bs *Bitswap) GetWantBlocks() []cid.Cid {
	return bs.pm.CurrentWantBlocks()
}

dirkmc's avatar
dirkmc committed
541 542 543
// GetWanthaves returns the current list of want-haves.
func (bs *Bitswap) GetWantHaves() []cid.Cid {
	return bs.pm.CurrentWantHaves()
544
}
545

546
// IsOnline is needed to match go-ipfs-exchange-interface
547 548 549
func (bs *Bitswap) IsOnline() bool {
	return true
}
550

551 552 553 554 555 556
// NewSession generates a new Bitswap session. You should use this, rather
// that calling Bitswap.GetBlocks, any time you intend to do several related
// block requests in a row. The session returned will have it's own GetBlocks
// method, but the session will use the fact that the requests are related to
// be more efficient in its requests to peers. If you are using a session
// from go-blockservice, it will create a bitswap session automatically.
557
func (bs *Bitswap) NewSession(ctx context.Context) exchange.Fetcher {
558
	return bs.sm.NewSession(ctx, bs.provSearchDelay, bs.rebroadcastDelay)
559
}