Skip to content

Commit 4a0b1eb

Browse files
committed
cmd: add debug forceautoloop cmd
1 parent ddc84fe commit 4a0b1eb

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

cmd/loop/debug.go

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//go:build dev
2+
// +build dev
3+
4+
package main
5+
6+
import (
7+
"context"
8+
9+
"github.com/lightninglabs/loop/looprpc"
10+
"github.com/urfave/cli"
11+
)
12+
13+
func init() {
14+
// Register the debug command.
15+
commands = append(commands, forceAutoloopCmd)
16+
}
17+
18+
var forceAutoloopCmd = cli.Command{
19+
Name: "forceautoloop",
20+
Usage: "forces a autoloop tick",
21+
Action: forceAutoloop,
22+
}
23+
24+
func forceAutoloop(ctx *cli.Context) error {
25+
client, cleanup, err := getDebugClient(ctx)
26+
if err != nil {
27+
return err
28+
}
29+
defer cleanup()
30+
31+
cfg, err := client.ForceAutoLoop(
32+
context.Background(), &looprpc.ForceAutoLoopRequest{},
33+
)
34+
if err != nil {
35+
return err
36+
}
37+
38+
printRespJSON(cfg)
39+
40+
return nil
41+
}
42+
43+
func getDebugClient(ctx *cli.Context) (looprpc.DebugClient, func(), error) {
44+
rpcServer := ctx.GlobalString("rpcserver")
45+
tlsCertPath, macaroonPath, err := extractPathArgs(ctx)
46+
if err != nil {
47+
return nil, nil, err
48+
}
49+
conn, err := getClientConn(rpcServer, tlsCertPath, macaroonPath)
50+
if err != nil {
51+
return nil, nil, err
52+
}
53+
cleanup := func() { conn.Close() }
54+
55+
debugClient := looprpc.NewDebugClient(conn)
56+
return debugClient, cleanup, nil
57+
}

0 commit comments

Comments
 (0)