mirror of
https://github.com/lightninglabs/loop
synced 2024-11-13 13:10:30 +00:00
39 lines
687 B
Go
39 lines
687 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/lightninglabs/loop/looprpc"
|
||
|
"github.com/urfave/cli"
|
||
|
)
|
||
|
|
||
|
var monitorCommand = cli.Command{
|
||
|
Name: "monitor",
|
||
|
Usage: "monitor progress of any active swaps",
|
||
|
Description: "Allows the user to monitor progress of any active swaps",
|
||
|
Action: monitor,
|
||
|
}
|
||
|
|
||
|
func monitor(ctx *cli.Context) error {
|
||
|
client, cleanup, err := getClient(ctx)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer cleanup()
|
||
|
|
||
|
stream, err := client.Monitor(
|
||
|
context.Background(), &looprpc.MonitorRequest{})
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
for {
|
||
|
swap, err := stream.Recv()
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("recv: %v", err)
|
||
|
}
|
||
|
logSwap(swap)
|
||
|
}
|
||
|
}
|