@@ -447,10 +447,13 @@ func (bb *BlocksBackend) streamCAR(ctx context.Context, p path.ImmutablePath, pa
447447 return
448448 }
449449
450- // Create DAG service with blocking detection
451- // TODO: Restore .Session(ctx) once https://github.com/ipfs-shipyard/nopfs/issues/34
452- // is resolved. Sessions improve performance but currently bypass denylist checks.
453- dagService := merkledag .NewDAGService (bb .blockService )
450+ // Create DAG service using the existing session from context if available
451+ // (embedded by WrapContextForRequest), or create a new one if needed.
452+ // blockservice.NewSession automatically handles session reuse, ensuring
453+ // all operations within a request share the same session for better performance.
454+ // Sessions properly enforce denylist checks via wrapped blockstore/exchange.
455+ session := blockservice .NewSession (ctx , bb .blockService )
456+ dagService := merkledag .WrapSession (session )
454457
455458 // Wrap DAG service to write blocks to CAR as they're fetched
456459 // This ensures all accessed blocks are included in the CAR output
@@ -534,9 +537,10 @@ func (bb *BlocksBackend) handleCarErrorPath(ctx context.Context, p path.Immutabl
534537 }
535538
536539 // Try to fetch just the root block to determine error type
537- // TODO: Restore .Session(ctx) once https://github.com/ipfs-shipyard/nopfs/issues/34
538- // is resolved. Sessions improve performance but currently bypass denylist checks.
539- dagService := merkledag .NewDAGService (bb .blockService )
540+ // Reuse existing session from context for consistency with other operations
541+ // in the same request. This improves performance through better peer management.
542+ session := blockservice .NewSession (ctx , bb .blockService )
543+ dagService := merkledag .WrapSession (session )
540544 _ , err := dagService .Get (ctx , rootCid )
541545
542546 if err != nil {
0 commit comments