refactor: daemon - simplify gateway cleanup
This commit is contained in:
parent
1ffdd7d5b3
commit
eec13ff8dc
@ -15,8 +15,6 @@ import (
|
|||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.uber.org/fx"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
paramfetch "github.com/filecoin-project/go-paramfetch"
|
paramfetch "github.com/filecoin-project/go-paramfetch"
|
||||||
@ -249,22 +247,24 @@ var DaemonCmd = &cli.Command{
|
|||||||
// If the daemon is started in "lite mode", replace the StateManager
|
// If the daemon is started in "lite mode", replace the StateManager
|
||||||
// with a thin client to a gateway server
|
// with a thin client to a gateway server
|
||||||
liteMode := node.Options()
|
liteMode := node.Options()
|
||||||
if cctx.Bool("lite") {
|
isLite := cctx.Bool("lite")
|
||||||
|
if isLite {
|
||||||
gapi, closer, err := lcli.GetGatewayAPI(cctx)
|
gapi, closer, err := lcli.GetGatewayAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
createRPCStateMgr := func(lc fx.Lifecycle) *modules.RPCStateManager {
|
defer closer()
|
||||||
lc.Append(fx.Hook{
|
|
||||||
OnStop: func(ctx context.Context) error {
|
liteMode = node.Options(
|
||||||
closer()
|
node.Override(new(api.GatewayAPI), gapi),
|
||||||
return nil
|
node.Override(new(stmgr.StateManagerAPI), modules.NewRPCStateManager),
|
||||||
},
|
node.Unset(node.RunHelloKey),
|
||||||
})
|
node.Unset(node.RunChainExchangeKey),
|
||||||
return modules.NewRPCStateManager(gapi)
|
node.Unset(node.RunPeerMgrKey),
|
||||||
}
|
node.Unset(node.HandleIncomingBlocksKey),
|
||||||
liteMode = node.Override(new(stmgr.StateManagerAPI), createRPCStateMgr)
|
node.Unset(node.HandleIncomingMessagesKey),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var api api.FullNode
|
var api api.FullNode
|
||||||
|
Loading…
Reference in New Issue
Block a user