From 625c6951bbe50789d5240da333ce34c4ea36837c Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 31 Aug 2020 19:24:04 +0200 Subject: [PATCH] Don't use context to close bitswap Use just the Close Signed-off-by: Jakub Sztandera --- node/modules/chain.go | 4 +++- node/modules/storageminer.go | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/node/modules/chain.go b/node/modules/chain.go index e121e47722..ea04945efa 100644 --- a/node/modules/chain.go +++ b/node/modules/chain.go @@ -38,7 +38,9 @@ func ChainExchange(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, rt // (so bitswap uses /chain/ipfs/bitswap/1.0.0 internally for chain sync stuff) bitswapNetwork := network.NewFromIpfsHost(host, rt, network.Prefix("/chain")) bitswapOptions := []bitswap.Option{bitswap.ProvideEnabled(false)} - exch := bitswap.New(helpers.LifecycleCtx(mctx, lc), bitswapNetwork, bs, bitswapOptions...) + + // Use just exch.Close(), closing the context is not needed + exch := bitswap.New(mctx, bitswapNetwork, bs, bitswapOptions...) lc.Append(fx.Hook{ OnStop: func(ctx context.Context) error { return exch.Close() diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 036561ef78..f79c8a370f 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -275,13 +275,14 @@ func StagingDAG(mctx helpers.MetricsCtx, lc fx.Lifecycle, ibs dtypes.StagingBloc bitswapNetwork := network.NewFromIpfsHost(h, rt) bitswapOptions := []bitswap.Option{bitswap.ProvideEnabled(false)} - exch := bitswap.New(helpers.LifecycleCtx(mctx, lc), bitswapNetwork, ibs, bitswapOptions...) + exch := bitswap.New(mctx, bitswapNetwork, ibs, bitswapOptions...) bsvc := blockservice.New(ibs, exch) dag := merkledag.NewDAGService(bsvc) lc.Append(fx.Hook{ OnStop: func(_ context.Context) error { + // blockservice closes the exchange return bsvc.Close() }, })