-
Notifications
You must be signed in to change notification settings - Fork 41
/
init_extensions.go
57 lines (46 loc) · 1.2 KB
/
init_extensions.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
package cmd
import (
"github.com/cosmos/cosmos-sdk/client"
cosmcfg "github.com/cosmos/cosmos-sdk/server/config"
"github.com/spf13/cobra"
tmcfg "github.com/tendermint/tendermint/config"
)
func extendInit(initCmd *cobra.Command) *cobra.Command {
baseRunE := initCmd.RunE
initCmd.RunE = func(cmd *cobra.Command, args []string) error {
err := baseRunE(cmd, args)
if err != nil {
return err
}
err = applyConfigDefaults(cmd)
if err != nil {
return err
}
return nil
}
return initCmd
}
func applyConfigDefaults(cmd *cobra.Command) error {
clientCtx := client.GetClientContextFromCmd(cmd)
err := updateTmConfig(clientCtx.HomeDir, func(config *tmcfg.Config) {
config.Consensus.CreateEmptyBlocks = false
config.FastSync.Version = "v0"
config.LogFormat = "json"
config.LogLevel = "error"
config.P2P.SendRate = 20000000
config.P2P.RecvRate = 20000000
config.P2P.MaxPacketMsgPayloadSize = 10240
// Workaround for Tendermint's bug
config.Storage = tmcfg.DefaultStorageConfig()
})
if err != nil {
return err
}
err = updateCosmConfig(clientCtx.HomeDir, func(config *cosmcfg.Config) {
config.BaseConfig.MinGasPrices = "50ncheq"
})
if err != nil {
return err
}
return nil
}