go-ethereum/internal/cli/dumpconfig.go
Arpit Temani 9fa20a7da8
Arpit/add execution pool 2 (#719)
* initial

* linters

* linters

* remove timeout

* update pool

* change pool size function

* check nil

* check nil

* fix tests

* Use execution pool from server in all handlers

* simplify things

* test fix

* add support for cli, config

* add to cli and config

* merge base branch

* debug statements

* fix bug

* atomic pointer timeout

* add apis

* update workerpool

* fix issues

* change params

* fix issues

* fix ipc issue

* remove execution pool from IPC

* revert

* fix tests

* mutex

* refactor flag and value names

* ordering fix

* refactor flag and value names

* update default ep size to 40

* fix bor start issues

* revert file changes

* debug statements

* fix bug

* update workerpool

* atomic pointer timeout

* add apis

* Merge branch 'add-execution-pool' of github.com:maticnetwork/bor into arpit/add-execution-pool

* fix issues

* change params

* fix issues

* fix ipc issue

* remove execution pool from IPC

* revert

* merge base branch

* Merge branch 'add-execution-pool' of github.com:maticnetwork/bor into arpit/add-execution-pool

* mutex

* fix tests

* Merge branch 'arpit/add-execution-pool' of github.com:maticnetwork/bor into arpit/add-execution-pool

* Change default size of execution pool to 40

* refactor flag and value names

* fix merge conflicts

* ordering fix

* refactor flag and value names

* update default ep size to 40

* fix bor start issues

* revert file changes

* fix linters

* fix go.mod

* change sec to ms

* change default value for ep timeout

* fix node api calls

* comment setter for ep timeout

---------

Co-authored-by: Evgeny Danienko <6655321@bk.ru>
Co-authored-by: Jerry <jerrycgh@gmail.com>
Co-authored-by: Manav Darji <manavdarji.india@gmail.com>
2023-02-03 18:22:57 +05:30

74 lines
2.5 KiB
Go

package cli
import (
"os"
"strings"
"github.com/BurntSushi/toml"
"github.com/ethereum/go-ethereum/internal/cli/server"
)
// DumpconfigCommand is for exporting user provided flags into a config file
type DumpconfigCommand struct {
*Meta2
}
// MarkDown implements cli.MarkDown interface
func (p *DumpconfigCommand) MarkDown() string {
items := []string{
"# Dumpconfig",
"The ```bor dumpconfig <your-favourite-flags>``` command will export the user provided flags into a configuration file",
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface
func (c *DumpconfigCommand) Help() string {
return `Usage: bor dumpconfig <your-favourite-flags>
This command will will export the user provided flags into a configuration file`
}
// Synopsis implements the cli.Command interface
func (c *DumpconfigCommand) Synopsis() string {
return "Export configuration file"
}
// TODO: add flags for file location and format (toml, json, hcl) of the configuration file.
// Run implements the cli.Command interface
func (c *DumpconfigCommand) Run(args []string) int {
// Initialize an empty command instance to get flags
command := server.Command{}
flags := command.Flags()
if err := flags.Parse(args); err != nil {
c.UI.Error(err.Error())
return 1
}
userConfig := command.GetConfig()
// convert the big.Int and time.Duration fields to their corresponding Raw fields
userConfig.JsonRPC.HttpTimeout.ReadTimeoutRaw = userConfig.JsonRPC.HttpTimeout.ReadTimeout.String()
userConfig.JsonRPC.HttpTimeout.WriteTimeoutRaw = userConfig.JsonRPC.HttpTimeout.WriteTimeout.String()
userConfig.JsonRPC.HttpTimeout.IdleTimeoutRaw = userConfig.JsonRPC.HttpTimeout.IdleTimeout.String()
userConfig.JsonRPC.Http.ExecutionPoolRequestTimeoutRaw = userConfig.JsonRPC.Http.ExecutionPoolRequestTimeout.String()
userConfig.JsonRPC.Ws.ExecutionPoolRequestTimeoutRaw = userConfig.JsonRPC.Ws.ExecutionPoolRequestTimeout.String()
userConfig.TxPool.RejournalRaw = userConfig.TxPool.Rejournal.String()
userConfig.TxPool.LifeTimeRaw = userConfig.TxPool.LifeTime.String()
userConfig.Sealer.GasPriceRaw = userConfig.Sealer.GasPrice.String()
userConfig.Gpo.MaxPriceRaw = userConfig.Gpo.MaxPrice.String()
userConfig.Gpo.IgnorePriceRaw = userConfig.Gpo.IgnorePrice.String()
userConfig.Cache.RejournalRaw = userConfig.Cache.Rejournal.String()
userConfig.Cache.TrieTimeoutRaw = userConfig.Cache.TrieTimeout.String()
if err := toml.NewEncoder(os.Stdout).Encode(userConfig); err != nil {
c.UI.Error(err.Error())
return 1
}
return 0
}