Skip to content

Commit

Permalink
Merge pull request ipfs/go-blockservice#28 from ipfs/fix/bs-131
Browse files Browse the repository at this point in the history
set the session context

This commit was moved from ipfs/go-blockservice@87a79d5
  • Loading branch information
hsanjuan committed May 24, 2019
2 parents a13f5d6 + 6bc6552 commit bd53d87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
12 changes: 7 additions & 5 deletions blockservice/blockservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ func NewSession(ctx context.Context, bs BlockService) *Session {
exch := bs.Exchange()
if sessEx, ok := exch.(exchange.SessionExchange); ok {
return &Session{
ses: nil,
sessEx: sessEx,
bs: bs.Blockstore(),
sessCtx: ctx,
ses: nil,
sessEx: sessEx,
bs: bs.Blockstore(),
}
}
return &Session{
ses: exch,
bs: bs.Blockstore(),
ses: exch,
sessCtx: ctx,
bs: bs.Blockstore(),
}
}

Expand Down
5 changes: 4 additions & 1 deletion blockservice/blockservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type fakeSessionExchange struct {
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
}
4 changes: 2 additions & 2 deletions blockservice/test/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package bstest
import (
. "github.com/ipfs/go-blockservice"

bitswap "github.com/ipfs/go-bitswap"
testinstance "github.com/ipfs/go-bitswap/testinstance"
tn "github.com/ipfs/go-bitswap/testnet"
delay "github.com/ipfs/go-ipfs-delay"
mockrouting "github.com/ipfs/go-ipfs-routing/mock"
Expand All @@ -12,7 +12,7 @@ import (
// Mocks returns |n| connected mock Blockservices
func Mocks(n int) []BlockService {
net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0))
sg := bitswap.NewTestSessionGenerator(net)
sg := testinstance.NewTestInstanceGenerator(net)

instances := sg.Instances(n)

Expand Down

0 comments on commit bd53d87

Please sign in to comment.