Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 87a79d5

Browse files
authored
Merge pull request #28 from ipfs/fix/bs-131
set the session context
2 parents 2c867f6 + fa64613 commit 87a79d5

File tree

5 files changed

+13
-64
lines changed

5 files changed

+13
-64
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ env:
1010
global:
1111
- GOTFLAGS="-race"
1212
matrix:
13-
- BUILD_DEPTYPE=gx
1413
- BUILD_DEPTYPE=gomod
1514

1615

@@ -24,7 +23,6 @@ script:
2423

2524
cache:
2625
directories:
27-
- $GOPATH/src/gx
2826
- $GOPATH/pkg/mod
2927
- $HOME/.cache/go-build
3028

blockservice.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,16 @@ func NewSession(ctx context.Context, bs BlockService) *Session {
115115
exch := bs.Exchange()
116116
if sessEx, ok := exch.(exchange.SessionExchange); ok {
117117
return &Session{
118-
ses: nil,
119-
sessEx: sessEx,
120-
bs: bs.Blockstore(),
118+
sessCtx: ctx,
119+
ses: nil,
120+
sessEx: sessEx,
121+
bs: bs.Blockstore(),
121122
}
122123
}
123124
return &Session{
124-
ses: exch,
125-
bs: bs.Blockstore(),
125+
ses: exch,
126+
sessCtx: ctx,
127+
bs: bs.Blockstore(),
126128
}
127129
}
128130

blockservice_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ type fakeSessionExchange struct {
102102
session exchange.Fetcher
103103
}
104104

105-
func (fe *fakeSessionExchange) NewSession(context.Context) exchange.Fetcher {
105+
func (fe *fakeSessionExchange) NewSession(ctx context.Context) exchange.Fetcher {
106+
if ctx == nil {
107+
panic("nil context")
108+
}
106109
return fe.session
107110
}

package.json

-54
This file was deleted.

test/mock.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package bstest
33
import (
44
. "github.com/ipfs/go-blockservice"
55

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

1717
instances := sg.Instances(n)
1818

0 commit comments

Comments
 (0)