Merge pull request #9783 from bitromortac/2505-loadmc-fixes
lncli: establish connection after parsing of mc data for loadmc
This commit is contained in:
2 files changed
+24
-33
No files matched your search
@@ -106,7 +106,7 @@ var loadMissionControlCommand = cli.Command{
|
|||||||
Name: "loadmc",
|
Name: "loadmc",
|
||||||
Category: "Mission Control",
|
Category: "Mission Control",
|
||||||
Usage: "Load mission control results to the internal mission " +
|
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 " +
|
"option to shift timestamps. Note that this data is not " +
|
||||||
"persisted across restarts.",
|
"persisted across restarts.",
|
||||||
Action: actionDecorator(loadMissionControl),
|
Action: actionDecorator(loadMissionControl),
|
||||||
@@ -115,19 +115,15 @@ var loadMissionControlCommand = cli.Command{
|
|||||||
Name: "mcdatapath",
|
Name: "mcdatapath",
|
||||||
Usage: "The path to the querymc output file (json).",
|
Usage: "The path to the querymc output file (json).",
|
||||||
},
|
},
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "discard",
|
|
||||||
Usage: "Discards current mission control data.",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "timeoffset",
|
Name: "timeoffset",
|
||||||
Usage: "Time offset to add to all timestamps. " +
|
Usage: "Time offset to add to all timestamps. " +
|
||||||
"Format: 1m for a minute, 1h for an hour, 1d " +
|
"Follows a format like 72h3m0.5s. " +
|
||||||
"for one day. This can be used to let " +
|
"This can be used to make mission control " +
|
||||||
"mission control data appear to be more " +
|
"data appear more recent, to trick " +
|
||||||
"recent, to trick pathfinding's in-built " +
|
"pathfinding's in-built information decay " +
|
||||||
"information decay mechanism. Additionally " +
|
"mechanism. Additionally, " +
|
||||||
"by setting 0m, this will report the most " +
|
"by setting 0s, this will report the most " +
|
||||||
"recent result timestamp, which can be used " +
|
"recent result timestamp, which can be used " +
|
||||||
"to find out how old this data is.",
|
"to find out how old this data is.",
|
||||||
},
|
},
|
||||||
@@ -137,6 +133,11 @@ var loadMissionControlCommand = cli.Command{
|
|||||||
"results in the database with older results " +
|
"results in the database with older results " +
|
||||||
"from the file.",
|
"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)
|
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.
|
// Load and unmarshal the querymc output file.
|
||||||
mcRaw, err := os.ReadFile(mcDataPath)
|
mcRaw, err := os.ReadFile(mcDataPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -171,21 +167,10 @@ func loadMissionControl(ctx *cli.Context) error {
|
|||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We discard mission control data if requested.
|
conn := getClientConn(ctx, false)
|
||||||
if ctx.Bool("discard") {
|
defer conn.Close()
|
||||||
if !promptForConfirmation("This will discard all current " +
|
|
||||||
"mission control data in the database (yes/no): ") {
|
|
||||||
|
|
||||||
return nil
|
client := routerrpc.NewRouterClient(conn)
|
||||||
}
|
|
||||||
|
|
||||||
_, err = client.ResetMissionControl(
|
|
||||||
rpcCtx, &routerrpc.ResetMissionControlRequest{},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a time offset to all timestamps if requested.
|
// Add a time offset to all timestamps if requested.
|
||||||
timeOffset := ctx.String("timeoffset")
|
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)
|
"New max timestamp: %v\n", offset, maxTimestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
sanitizeMCData(mc.Pairs)
|
sanitizeMCData(mc.Pairs)
|
||||||
|
|
||||||
fmt.Printf("Mission control file contains %v pairs.\n", len(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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -251,7 +251,9 @@ when running LND with an aux component injected (custom channels).
|
|||||||
specific IPs could be allowed or denied.
|
specific IPs could be allowed or denied.
|
||||||
|
|
||||||
* A [command was created](https://github.com/lightningnetwork/lnd/pull/9781) to
|
* 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
|
# Improvements
|
||||||
## Functional Updates
|
## Functional Updates
|
||||||
|
|||||||
Reference in new issue
Block a user