Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fast sync version configuration command (#205) #206

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions cmd/cheqd-noded/cmd/configure.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package cmd

import (
"strconv"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
cosmcfg "github.com/cosmos/cosmos-sdk/server/config"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/spf13/cobra"
tmcfg "github.com/tendermint/tendermint/config"
"strconv"
)

// configureCmd returns configure cobra Command.
Expand All @@ -21,7 +22,8 @@ func configureCmd(defaultNodeHome string) *cobra.Command {
minGasPricesCmd(defaultNodeHome),
p2pCmd(defaultNodeHome),
rpcLaddrCmd(defaultNodeHome),
createEmptyBlocksCmd(defaultNodeHome))
createEmptyBlocksCmd(defaultNodeHome),
fastsyncVersionCmd(defaultNodeHome))

return cmd
}
Expand Down Expand Up @@ -50,7 +52,7 @@ func minGasPricesCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "min-gas-prices [value]",
Short: "Update min-gas-prices value in app.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -70,7 +72,7 @@ func seedModeCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "seed-mode [value]",
Short: "Update seed-mode value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -95,7 +97,7 @@ func seedsCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "seeds [value]",
Short: "Update seeds value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -115,7 +117,7 @@ func externalAddressCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "external-address [value]",
Short: "Update external-address value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -135,7 +137,7 @@ func persistentPeersCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "persistent-peers [value]",
Short: "Update persistent-peers value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -155,7 +157,7 @@ func sendRateCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "send-rate [value]",
Short: "Update send-rate value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -180,7 +182,7 @@ func recvRateCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "recv-rate [value]",
Short: "Update recv-rate value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -205,7 +207,7 @@ func maxPacketMsgPayloadSizeCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "max-packet-msg-payload-size [value]",
Short: "Update max-packet-msg-payload-size value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -230,7 +232,7 @@ func createEmptyBlocksCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "create-empty-blocks [value]",
Short: "Update create-empty-blocks value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -255,7 +257,7 @@ func rpcLaddrCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "rpc-laddr [value]",
Short: "Update rpc.laddr value in config.toml",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand All @@ -269,3 +271,23 @@ func rpcLaddrCmd(defaultNodeHome string) *cobra.Command {

return cmd
}

// fastsyncVersionCmd returns configuration cobra Command.
func fastsyncVersionCmd(defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "fastsync-version [value]",
Short: "Update fastsync.version value in config.toml",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

return updateTmConfig(clientCtx.HomeDir, func(config *tmcfg.Config) {
config.FastSync.Version = args[0]
})
},
}

cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")

return cmd
}