-
Notifications
You must be signed in to change notification settings - Fork 4
/
agent_refresh_routes.go
46 lines (37 loc) · 1017 Bytes
/
agent_refresh_routes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package cmd
import (
"fmt"
"time"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)
var refreshRoutesCmd = &cobra.Command{
Use: "refresh-routes",
Short: "Update cached routes on your Agent",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
ctx := cmd.Context()
from := cmd.Flag("from").Value.String()
agentAddr, auth, _, _, err := commonOwnerOrOperatorSetup(ctx, from)
if err != nil {
logFatal(err)
}
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
s.Start()
defer s.Stop()
tx, err := PoolsSDK.Act().AgentRefreshRoutes(ctx, auth, agentAddr)
if err != nil {
logFatalf("Failed to refresh routes %s", err)
}
_, err = PoolsSDK.Query().StateWaitReceipt(ctx, tx.Hash())
if err != nil {
logFatalf("Failed to refresh routes %s", err)
}
s.Stop()
fmt.Printf("Routes refreshed!\n")
},
}
func init() {
agentCmd.AddCommand(refreshRoutesCmd)
refreshRoutesCmd.Flags().String("from", "", "address to send the transaction from")
}