From fda73d4fd6805f9ebb2bb90d906d54f1cab160db Mon Sep 17 00:00:00 2001 From: Alexander Kolesov Date: Thu, 11 Nov 2021 20:57:42 +0300 Subject: [PATCH] Add configure p2p laddr command --- cmd/cheqd-noded/cmd/configure.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cmd/cheqd-noded/cmd/configure.go b/cmd/cheqd-noded/cmd/configure.go index 8a85300a8..3c5c38a19 100644 --- a/cmd/cheqd-noded/cmd/configure.go +++ b/cmd/cheqd-noded/cmd/configure.go @@ -42,7 +42,8 @@ func p2pCmd(defaultNodeHome string) *cobra.Command { persistentPeersCmd(defaultNodeHome), sendRateCmd(defaultNodeHome), recvRateCmd(defaultNodeHome), - maxPacketMsgPayloadSizeCmd(defaultNodeHome)) + maxPacketMsgPayloadSizeCmd(defaultNodeHome), + p2pLaddrCmd(defaultNodeHome)) return cmd } @@ -227,6 +228,26 @@ func maxPacketMsgPayloadSizeCmd(defaultNodeHome string) *cobra.Command { return cmd } +// p2pLaddrCmd returns configuration cobra Command. +func p2pLaddrCmd(defaultNodeHome string) *cobra.Command { + cmd := &cobra.Command{ + Use: "laddr [value]", + Short: "Update p2p.laddr 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.P2P.ListenAddress = args[0] + }) + }, + } + + cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory") + + return cmd +} + // createEmptyBlocksCmd returns configuration cobra Command. func createEmptyBlocksCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{