Skip to content

Commit 344aeb8

Browse files
authored
feat(shwap/bitswap): disable session pruning with env var (#4201)
This is allows us to test the theory behind #4199. We can merge it to the main s.t. we can also ask our partners to toggle it and see results for them.
1 parent eb24ab5 commit 344aeb8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

share/shwap/p2p/bitswap/getter.go

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bitswap
33
import (
44
"context"
55
"fmt"
6+
"os"
67
"sync"
78
"time"
89

@@ -23,6 +24,8 @@ import (
2324
"github.com/celestiaorg/celestia-node/share/shwap"
2425
)
2526

27+
var disablePooling = os.Getenv("CELESTIA_BITSWAP_DISABLE_POOLING") == "1"
28+
2629
var tracer = otel.Tracer("shwap/bitswap")
2730

2831
// Getter implements share.Getter.
@@ -275,6 +278,12 @@ func (g *Getter) isArchival(hdr *header.ExtendedHeader) bool {
275278

276279
// getSession takes a session out of the respective session pool
277280
func (g *Getter) getSession(isArchival bool) (ses exchange.Fetcher, release func()) {
281+
if disablePooling {
282+
ctx, cancel := context.WithCancel(context.Background())
283+
f := g.exchange.NewSession(ctx)
284+
return f, cancel
285+
}
286+
278287
if isArchival {
279288
ses = g.archivalPool.get()
280289
return ses, func() { g.archivalPool.put(ses) }

0 commit comments

Comments
 (0)