Skip to content

Commit

Permalink
fix test (#4670)
Browse files Browse the repository at this point in the history
* fix test
  • Loading branch information
simlecode authored Jan 5, 2022
1 parent e54464d commit 22a9f7a
Showing 1 changed file with 19 additions and 14 deletions.
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

0 comments on commit 22a9f7a

Please sign in to comment.