-
Notifications
You must be signed in to change notification settings - Fork 203
/
tx_freeze.go
58 lines (49 loc) · 1.88 KB
/
tx_freeze.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
47
48
49
50
51
52
53
54
55
56
57
58
package cli
import (
"strconv"
"strings"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/lavanet/lava/utils"
"github.com/lavanet/lava/x/pairing/types"
"github.com/spf13/cobra"
)
var _ = strconv.Itoa(0)
func CmdFreeze() *cobra.Command {
cmd := &cobra.Command{
Use: "freeze [chain-ids]",
Short: "Freezes a provider",
Long: `The freeze command allows a provider to freeze its service, effective next epoch. This allows providers to pause their services without the impact of bad QoS rating. While frozen, the provider won't be paired with consumers. To unfreeze, the provider must use the unfreeze transaction. Example use case: a provider wishes to halt its services during maintenance.`,
Example: `required flags: --from alice. optional flags: --reason
lavad tx pairing freeze [chain-ids] --from <provider_address>
lavad tx pairing freeze [chain-ids] --from <provider_address> --reason <freeze_reason>
lavad tx pairing freeze ETH1,COS3 --from alice --reason "maintenance"`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argChainIds := strings.Split(args[0], listSeparator)
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
// get the freeze reason (default value: "")
reason, err := cmd.Flags().GetString(types.ReasonFlagName)
if err != nil {
utils.LavaFormatFatal("failed to read freeze reason flag", err)
}
msg := types.NewMsgFreeze(
clientCtx.GetFromAddress().String(),
argChainIds,
reason,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
cmd.MarkFlagRequired(flags.FlagFrom)
cmd.Flags().String(types.ReasonFlagName, "", "reason for freeze")
return cmd
}