Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test #4670

Merged
merged 2 commits into from
Jan 5, 2022
Merged
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
33 changes: 19 additions & 14 deletions app/submodule/network/network_submodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ type NetworkSubmodule struct { //nolint
//data transfer
DataTransfer datatransfer.Manager
DataTransferHost dtnet.DataTransferNetwork

// fix datastore closed before flush
cancel context.CancelFunc
}

//API create a new network implement
Expand All @@ -96,6 +99,7 @@ func (networkSubmodule *NetworkSubmodule) Stop(ctx context.Context) {
if err := networkSubmodule.Host.Close(); err != nil {
networkLogger.Errorf("error closing host: %s", err.Error())
}
networkSubmodule.cancel()
}

type networkConfig interface {
Expand Down Expand Up @@ -134,7 +138,8 @@ func NewNetworkSubmodule(ctx context.Context, config networkConfig) (*NetworkSub
var router routing.Routing
var pubsubMessageSigning bool
var peerMgr net.IPeerMgr
// if !config.OfflineMode() {
networkSubmodule := &NetworkSubmodule{}
ctx, networkSubmodule.cancel = context.WithCancel(ctx)
makeDHT := func(h host.Host) (routing.Routing, error) {
mode := dht.ModeAuto
opts := []dht.Option{dht.Mode(mode),
Expand Down Expand Up @@ -238,19 +243,19 @@ func NewNetworkSubmodule(ctx context.Context, config networkConfig) (*NetworkSub
network := net.New(peerHost, net.NewRouter(router), bandwidthTracker)

// build the network submdule
return &NetworkSubmodule{
NetworkName: networkName,
Host: peerHost,
Router: router,
Pubsub: gsub,
Bitswap: bswap,
GraphExchange: gsync,
Network: network,
DataTransfer: dt,
DataTransferHost: dtNet,
PeerMgr: peerMgr,
Blockstore: config.Repo().Datastore(),
}, nil
networkSubmodule.NetworkName = networkName
networkSubmodule.Host = peerHost
networkSubmodule.Router = router
networkSubmodule.Pubsub = gsub
networkSubmodule.Bitswap = bswap
networkSubmodule.GraphExchange = gsync
networkSubmodule.Network = network
networkSubmodule.DataTransfer = dt
networkSubmodule.DataTransferHost = dtNet
networkSubmodule.PeerMgr = peerMgr
networkSubmodule.Blockstore = config.Repo().Datastore()

return networkSubmodule, nil
}

func (networkSubmodule *NetworkSubmodule) FetchMessagesByCids(
Expand Down