From 5d7285b201e01a3fdb92d15d752cb8ccbaf5cd18 Mon Sep 17 00:00:00 2001 From: Masanori Yoshida Date: Mon, 23 Oct 2023 17:55:06 +0900 Subject: [PATCH] add "--do-refresh" option to `tx relay/acks` subcommands Signed-off-by: Masanori Yoshida --- cmd/tx.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/tx.go b/cmd/tx.go index 780a5dce..49237450 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -8,6 +8,7 @@ import ( "github.com/hyperledger-labs/yui-relayer/config" "github.com/hyperledger-labs/yui-relayer/core" "github.com/spf13/cobra" + "github.com/spf13/viper" ) // transactionCmd represents the tx command @@ -157,6 +158,12 @@ func createChannelCmd(ctx *config.Context) *cobra.Command { } func relayMsgsCmd(ctx *config.Context) *cobra.Command { + const ( + flagDoRefresh = "do-refresh" + ) + const ( + defaultDoRefresh = false + ) cmd := &cobra.Command{ Use: "relay [path-name]", Short: "relay any packets that remain to be relayed on a given path, in both directions", @@ -188,7 +195,7 @@ func relayMsgsCmd(ctx *config.Context) *cobra.Command { return err } - if err := st.UpdateClients(c[src], c[dst], sp, &core.RelayPackets{}, sh, false); err != nil { + if err := st.UpdateClients(c[src], c[dst], sp, &core.RelayPackets{}, sh, viper.GetBool(flagDoRefresh)); err != nil { return err } @@ -199,11 +206,18 @@ func relayMsgsCmd(ctx *config.Context) *cobra.Command { return nil }, } + cmd.Flags().Bool(flagDoRefresh, defaultDoRefresh, "execute light client refresh (updateClient) if required") // TODO add option support for strategy return cmd } func relayAcksCmd(ctx *config.Context) *cobra.Command { + const ( + flagDoRefresh = "do-refresh" + ) + const ( + defaultDoRefresh = false + ) cmd := &cobra.Command{ Use: "relay-acknowledgements [path-name]", Aliases: []string{"acks"}, @@ -234,7 +248,7 @@ func relayAcksCmd(ctx *config.Context) *cobra.Command { return err } - if err := st.UpdateClients(c[src], c[dst], &core.RelayPackets{}, sp, sh, false); err != nil { + if err := st.UpdateClients(c[src], c[dst], &core.RelayPackets{}, sp, sh, viper.GetBool(flagDoRefresh)); err != nil { return err } @@ -245,6 +259,6 @@ func relayAcksCmd(ctx *config.Context) *cobra.Command { return nil }, } - + cmd.Flags().Bool(flagDoRefresh, defaultDoRefresh, "execute light client refresh (updateClient) if required") return cmd }