diff --git a/cmd/commands/cmd_import_mission_control.go b/cmd/commands/cmd_import_mission_control.go index 8bc69729b..1fb63c859 100644 --- a/cmd/commands/cmd_import_mission_control.go +++ b/cmd/commands/cmd_import_mission_control.go @@ -106,7 +106,7 @@ var loadMissionControlCommand = cli.Command{ Name: "loadmc", Category: "Mission Control", Usage: "Load mission control results to the internal mission " + - "control state from a file produced by querymc with the " + + "control state from a file produced by `querymc` with the " + "option to shift timestamps. Note that this data is not " + "persisted across restarts.", Action: actionDecorator(loadMissionControl), @@ -115,19 +115,15 @@ var loadMissionControlCommand = cli.Command{ Name: "mcdatapath", Usage: "The path to the querymc output file (json).", }, - cli.BoolFlag{ - Name: "discard", - Usage: "Discards current mission control data.", - }, cli.StringFlag{ Name: "timeoffset", Usage: "Time offset to add to all timestamps. " + - "Format: 1m for a minute, 1h for an hour, 1d " + - "for one day. This can be used to let " + - "mission control data appear to be more " + - "recent, to trick pathfinding's in-built " + - "information decay mechanism. Additionally " + - "by setting 0m, this will report the most " + + "Follows a format like 72h3m0.5s. " + + "This can be used to make mission control " + + "data appear more recent, to trick " + + "pathfinding's in-built information decay " + + "mechanism. Additionally, " + + "by setting 0s, this will report the most " + "recent result timestamp, which can be used " + "to find out how old this data is.", }, @@ -137,6 +133,11 @@ var loadMissionControlCommand = cli.Command{ "results in the database with older results " + "from the file.", }, + cli.BoolFlag{ + Name: "skip_confirmation", + Usage: "Skip the confirmation prompt and import " + + "immediately", + }, }, } @@ -153,11 +154,6 @@ func loadMissionControl(ctx *cli.Context) error { return fmt.Errorf("%v does not exist", mcDataPath) } - conn := getClientConn(ctx, false) - defer conn.Close() - - client := routerrpc.NewRouterClient(conn) - // Load and unmarshal the querymc output file. mcRaw, err := os.ReadFile(mcDataPath) if err != nil { @@ -171,21 +167,10 @@ func loadMissionControl(ctx *cli.Context) error { err) } - // We discard mission control data if requested. - if ctx.Bool("discard") { - if !promptForConfirmation("This will discard all current " + - "mission control data in the database (yes/no): ") { + conn := getClientConn(ctx, false) + defer conn.Close() - return nil - } - - _, err = client.ResetMissionControl( - rpcCtx, &routerrpc.ResetMissionControlRequest{}, - ) - if err != nil { - return err - } - } + client := routerrpc.NewRouterClient(conn) // Add a time offset to all timestamps if requested. timeOffset := ctx.String("timeoffset") @@ -222,14 +207,18 @@ func loadMissionControl(ctx *cli.Context) error { } } - fmt.Printf("Adding time offset %v to all timestamps. "+ + fmt.Printf("Added a time offset %v to all timestamps. "+ "New max timestamp: %v\n", offset, maxTimestamp) } sanitizeMCData(mc.Pairs) fmt.Printf("Mission control file contains %v pairs.\n", len(mc.Pairs)) - if !promptForConfirmation("Import mission control data (yes/no): ") { + if !ctx.Bool("skip_confirmation") && + !promptForConfirmation( + "Import mission control data (yes/no): ", + ) { + return nil } diff --git a/docs/release-notes/release-notes-0.19.0.md b/docs/release-notes/release-notes-0.19.0.md index 5893fc11f..2a9f9e325 100644 --- a/docs/release-notes/release-notes-0.19.0.md +++ b/docs/release-notes/release-notes-0.19.0.md @@ -251,7 +251,9 @@ when running LND with an aux component injected (custom channels). specific IPs could be allowed or denied. * A [command was created](https://github.com/lightningnetwork/lnd/pull/9781) to - load mission control data generated by `lncli querymc`. + load mission control data generated by `lncli querymc`. `loadmc` [also + accepts](https://github.com/lightningnetwork/lnd/pull/9783) a flag + `skip_confirmation` to make the command scriptable. # Improvements ## Functional Updates