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

set the session context #28

Merged
merged 3 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ env:
global:
- GOTFLAGS="-race"
matrix:
- BUILD_DEPTYPE=gx
- BUILD_DEPTYPE=gomod


Expand All @@ -24,7 +23,6 @@ script:

cache:
directories:
- $GOPATH/src/gx
- $GOPATH/pkg/mod
- $HOME/.cache/go-build

Expand Down
12 changes: 7 additions & 5 deletions 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_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
}
54 changes: 0 additions & 54 deletions package.json

This file was deleted.

4 changes: 2 additions & 2 deletions 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