Commit 6013394c authored by Steven Allen's avatar Steven Allen

set the session context

fixes https://github.com/ipfs/go-bitswap/issues/131
parent b46b687f
...@@ -115,6 +115,7 @@ func NewSession(ctx context.Context, bs BlockService) *Session { ...@@ -115,6 +115,7 @@ func NewSession(ctx context.Context, bs BlockService) *Session {
exch := bs.Exchange() exch := bs.Exchange()
if sessEx, ok := exch.(exchange.SessionExchange); ok { if sessEx, ok := exch.(exchange.SessionExchange); ok {
return &Session{ return &Session{
sessCtx: ctx,
ses: nil, ses: nil,
sessEx: sessEx, sessEx: sessEx,
bs: bs.Blockstore(), bs: bs.Blockstore(),
...@@ -122,6 +123,7 @@ func NewSession(ctx context.Context, bs BlockService) *Session { ...@@ -122,6 +123,7 @@ func NewSession(ctx context.Context, bs BlockService) *Session {
} }
return &Session{ return &Session{
ses: exch, ses: exch,
sessCtx: ctx,
bs: bs.Blockstore(), bs: bs.Blockstore(),
} }
} }
......
...@@ -102,6 +102,9 @@ type fakeSessionExchange struct { ...@@ -102,6 +102,9 @@ type fakeSessionExchange struct {
session exchange.Fetcher session exchange.Fetcher
} }
func (fe *fakeSessionExchange) NewSession(context.Context) exchange.Fetcher { func (fe *fakeSessionExchange) NewSession(ctx context.Context) exchange.Fetcher {
if ctx == nil {
panic("nil context")
}
return fe.session return fe.session
} }
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