mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
Remove pointers in config field
This commit is contained in:
parent
2b7bd156cf
commit
3d3f986c5b
5 changed files with 325 additions and 336 deletions
|
|
@ -78,9 +78,10 @@ func (f *Flagset) StringFlag(b *StringFlag) {
|
|||
}
|
||||
|
||||
type IntFlag struct {
|
||||
Name string
|
||||
Usage string
|
||||
Value *int
|
||||
Name string
|
||||
Usage string
|
||||
Value *int
|
||||
Default int
|
||||
}
|
||||
|
||||
func (f *Flagset) IntFlag(i *IntFlag) {
|
||||
|
|
@ -88,13 +89,14 @@ func (f *Flagset) IntFlag(i *IntFlag) {
|
|||
Name: i.Name,
|
||||
Usage: i.Usage,
|
||||
})
|
||||
f.set.IntVar(i.Value, i.Name, *i.Value, i.Usage)
|
||||
f.set.IntVar(i.Value, i.Name, i.Default, i.Usage)
|
||||
}
|
||||
|
||||
type Uint64Flag struct {
|
||||
Name string
|
||||
Usage string
|
||||
Value *uint64
|
||||
Name string
|
||||
Usage string
|
||||
Value *uint64
|
||||
Default uint64
|
||||
}
|
||||
|
||||
func (f *Flagset) Uint64Flag(i *Uint64Flag) {
|
||||
|
|
@ -102,7 +104,7 @@ func (f *Flagset) Uint64Flag(i *Uint64Flag) {
|
|||
Name: i.Name,
|
||||
Usage: i.Usage,
|
||||
})
|
||||
f.set.Uint64Var(i.Value, i.Name, *i.Value, i.Usage)
|
||||
f.set.Uint64Var(i.Value, i.Name, i.Default, i.Usage)
|
||||
}
|
||||
|
||||
type BigIntFlag struct {
|
||||
|
|
@ -169,9 +171,10 @@ func (f *Flagset) SliceStringFlag(s *SliceStringFlag) {
|
|||
}
|
||||
|
||||
type DurationFlag struct {
|
||||
Name string
|
||||
Usage string
|
||||
Value *time.Duration
|
||||
Name string
|
||||
Usage string
|
||||
Value *time.Duration
|
||||
Default time.Duration
|
||||
}
|
||||
|
||||
func (f *Flagset) DurationFlag(d *DurationFlag) {
|
||||
|
|
@ -179,7 +182,7 @@ func (f *Flagset) DurationFlag(d *DurationFlag) {
|
|||
Name: d.Name,
|
||||
Usage: d.Usage,
|
||||
})
|
||||
f.set.DurationVar(d.Value, d.Name, *d.Value, "")
|
||||
f.set.DurationVar(d.Value, d.Name, d.Default, "")
|
||||
}
|
||||
|
||||
type MapStringFlag struct {
|
||||
|
|
@ -224,9 +227,10 @@ func (f *Flagset) MapStringFlag(m *MapStringFlag) {
|
|||
}
|
||||
|
||||
type Float64Flag struct {
|
||||
Name string
|
||||
Usage string
|
||||
Value *float64
|
||||
Name string
|
||||
Usage string
|
||||
Value *float64
|
||||
Default float64
|
||||
}
|
||||
|
||||
func (f *Flagset) Float64Flag(i *Float64Flag) {
|
||||
|
|
@ -234,5 +238,5 @@ func (f *Flagset) Float64Flag(i *Float64Flag) {
|
|||
Name: i.Name,
|
||||
Usage: i.Usage,
|
||||
})
|
||||
f.set.Float64Var(i.Value, i.Name, *i.Value, "")
|
||||
f.set.Float64Var(i.Value, i.Name, i.Default, "")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ func (c *Command) Run(args []string) int {
|
|||
c.config = config
|
||||
|
||||
// start the logger
|
||||
setupLogger(*config.LogLevel)
|
||||
setupLogger(config.LogLevel)
|
||||
|
||||
// load the chain genesis
|
||||
if err := config.loadChain(); err != nil {
|
||||
|
|
@ -122,7 +122,7 @@ func (c *Command) Run(args []string) int {
|
|||
stack.RegisterAPIs(tracers.APIs(backend.APIBackend))
|
||||
|
||||
// graphql is started from another place
|
||||
if *config.JsonRPC.Graphql.Enabled {
|
||||
if config.JsonRPC.Graphql.Enabled {
|
||||
if err := graphql.New(stack, backend.APIBackend, config.JsonRPC.Cors, config.JsonRPC.Modules); err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Failed to register the GraphQL service: %v", err))
|
||||
return 1
|
||||
|
|
@ -130,8 +130,8 @@ func (c *Command) Run(args []string) int {
|
|||
}
|
||||
|
||||
// register ethash service
|
||||
if *config.EthStats != "" {
|
||||
if err := ethstats.New(stack, backend.APIBackend, backend.Engine(), *config.EthStats); err != nil {
|
||||
if config.EthStats != "" {
|
||||
if err := ethstats.New(stack, backend.APIBackend, backend.Engine(), config.EthStats); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ func (c *Command) Run(args []string) int {
|
|||
{
|
||||
keydir := stack.KeyStoreDir()
|
||||
n, p := keystore.StandardScryptN, keystore.StandardScryptP
|
||||
if *config.Accounts.UseLightweightKDF {
|
||||
if config.Accounts.UseLightweightKDF {
|
||||
n, p = keystore.LightScryptN, keystore.LightScryptP
|
||||
}
|
||||
borKeystore = keystore.NewKeyStore(keydir, n, p)
|
||||
|
|
@ -158,7 +158,7 @@ func (c *Command) Run(args []string) int {
|
|||
}
|
||||
|
||||
// sealing (if enabled)
|
||||
if *config.Sealer.Enabled {
|
||||
if config.Sealer.Enabled {
|
||||
if err := backend.StartMining(1); err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
|
|
@ -186,9 +186,9 @@ func (c *Command) unlockAccounts(borKeystore *keystore.KeyStore) error {
|
|||
|
||||
// read passwords from file if possible
|
||||
passwords := []string{}
|
||||
if *c.config.Accounts.PasswordFile != "" {
|
||||
if c.config.Accounts.PasswordFile != "" {
|
||||
var err error
|
||||
if passwords, err = readMultilineFile(*c.config.Accounts.PasswordFile); err != nil {
|
||||
if passwords, err = readMultilineFile(c.config.Accounts.PasswordFile); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
@ -222,8 +222,8 @@ func (c *Command) unlockAccounts(borKeystore *keystore.KeyStore) error {
|
|||
}
|
||||
|
||||
func (c *Command) setupMetrics(config *MetricsConfig) error {
|
||||
metrics.Enabled = *config.Enabled
|
||||
metrics.EnabledExpensive = *config.Expensive
|
||||
metrics.Enabled = config.Enabled
|
||||
metrics.EnabledExpensive = config.Expensive
|
||||
|
||||
if !metrics.Enabled {
|
||||
// metrics are disabled, do not set up any sink
|
||||
|
|
@ -233,22 +233,22 @@ func (c *Command) setupMetrics(config *MetricsConfig) error {
|
|||
log.Info("Enabling metrics collection")
|
||||
|
||||
// influxdb
|
||||
if v1Enabled, v2Enabled := (*config.InfluxDB.V1Enabled), (*config.InfluxDB.V2Enabled); v1Enabled || v2Enabled {
|
||||
if v1Enabled, v2Enabled := (config.InfluxDB.V1Enabled), (config.InfluxDB.V2Enabled); v1Enabled || v2Enabled {
|
||||
if v1Enabled && v2Enabled {
|
||||
return fmt.Errorf("both influx v1 and influx v2 cannot be enabled")
|
||||
}
|
||||
|
||||
cfg := config.InfluxDB
|
||||
tags := *cfg.Tags
|
||||
endpoint := *cfg.Endpoint
|
||||
tags := cfg.Tags
|
||||
endpoint := cfg.Endpoint
|
||||
|
||||
if v1Enabled {
|
||||
log.Info("Enabling metrics export to InfluxDB (v1)")
|
||||
go influxdb.InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, *cfg.Database, *cfg.Username, *cfg.Password, "geth.", tags)
|
||||
go influxdb.InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, cfg.Database, cfg.Username, cfg.Password, "geth.", tags)
|
||||
}
|
||||
if v2Enabled {
|
||||
log.Info("Enabling metrics export to InfluxDB (v2)")
|
||||
go influxdb.InfluxDBV2WithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, *cfg.Token, *cfg.Bucket, *cfg.Organization, "geth.", tags)
|
||||
go influxdb.InfluxDBV2WithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, cfg.Token, cfg.Bucket, cfg.Organization, "geth.", tags)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,66 +30,42 @@ import (
|
|||
gopsutil "github.com/shirou/gopsutil/mem"
|
||||
)
|
||||
|
||||
func mapStrPtr(m map[string]string) *map[string]string {
|
||||
return &m
|
||||
}
|
||||
|
||||
func stringPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func float64Ptr(f float64) *float64 {
|
||||
return &f
|
||||
}
|
||||
|
||||
func uint64Ptr(i uint64) *uint64 {
|
||||
return &i
|
||||
}
|
||||
|
||||
func boolPtr(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
func durPtr(d time.Duration) *time.Duration {
|
||||
return &d
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
chain *chains.Chain
|
||||
|
||||
Chain *string
|
||||
Debug *bool
|
||||
Whitelist *map[string]string
|
||||
LogLevel *string
|
||||
DataDir *string
|
||||
Chain string
|
||||
Debug bool
|
||||
Whitelist map[string]string
|
||||
LogLevel string
|
||||
DataDir string
|
||||
P2P *P2PConfig
|
||||
SyncMode *string
|
||||
GcMode *string
|
||||
Snapshot *bool
|
||||
EthStats *string
|
||||
SyncMode string
|
||||
GcMode string
|
||||
Snapshot bool
|
||||
EthStats string
|
||||
Heimdall *HeimdallConfig
|
||||
TxPool *TxPoolConfig
|
||||
Sealer *SealerConfig
|
||||
JsonRPC *JsonRPCConfig
|
||||
Gpo *GpoConfig
|
||||
Ethstats *string
|
||||
Ethstats string
|
||||
Metrics *MetricsConfig
|
||||
Cache *CacheConfig
|
||||
Accounts *AccountsConfig
|
||||
}
|
||||
|
||||
type P2PConfig struct {
|
||||
MaxPeers *uint64
|
||||
MaxPendPeers *uint64
|
||||
Bind *string
|
||||
Port *uint64
|
||||
NoDiscover *bool
|
||||
NAT *string
|
||||
MaxPeers uint64
|
||||
MaxPendPeers uint64
|
||||
Bind string
|
||||
Port uint64
|
||||
NoDiscover bool
|
||||
NAT string
|
||||
Discovery *P2PDiscovery
|
||||
}
|
||||
|
||||
type P2PDiscovery struct {
|
||||
V5Enabled *bool
|
||||
V5Enabled bool
|
||||
Bootnodes []string
|
||||
BootnodesV4 []string
|
||||
BootnodesV5 []string
|
||||
|
|
@ -99,42 +75,42 @@ type P2PDiscovery struct {
|
|||
}
|
||||
|
||||
type HeimdallConfig struct {
|
||||
URL *string
|
||||
Without *bool
|
||||
URL string
|
||||
Without bool
|
||||
}
|
||||
|
||||
type TxPoolConfig struct {
|
||||
Locals []string
|
||||
NoLocals *bool
|
||||
Journal *string
|
||||
Rejournal *time.Duration
|
||||
PriceLimit *uint64
|
||||
PriceBump *uint64
|
||||
AccountSlots *uint64
|
||||
GlobalSlots *uint64
|
||||
AccountQueue *uint64
|
||||
GlobalQueue *uint64
|
||||
LifeTime *time.Duration
|
||||
NoLocals bool
|
||||
Journal string
|
||||
Rejournal time.Duration
|
||||
PriceLimit uint64
|
||||
PriceBump uint64
|
||||
AccountSlots uint64
|
||||
GlobalSlots uint64
|
||||
AccountQueue uint64
|
||||
GlobalQueue uint64
|
||||
LifeTime time.Duration
|
||||
}
|
||||
|
||||
type SealerConfig struct {
|
||||
Enabled *bool
|
||||
Etherbase *string
|
||||
ExtraData *string
|
||||
GasCeil *uint64
|
||||
Enabled bool
|
||||
Etherbase string
|
||||
ExtraData string
|
||||
GasCeil uint64
|
||||
GasPrice *big.Int
|
||||
}
|
||||
|
||||
type JsonRPCConfig struct {
|
||||
IPCDisable *bool
|
||||
IPCPath *string
|
||||
IPCDisable bool
|
||||
IPCPath string
|
||||
|
||||
Modules []string
|
||||
VHost []string
|
||||
Cors []string
|
||||
|
||||
GasCap *uint64
|
||||
TxFeeCap *float64
|
||||
GasCap uint64
|
||||
TxFeeCap float64
|
||||
|
||||
Http *APIConfig
|
||||
Ws *APIConfig
|
||||
|
|
@ -142,74 +118,74 @@ type JsonRPCConfig struct {
|
|||
}
|
||||
|
||||
type APIConfig struct {
|
||||
Enabled *bool
|
||||
Port *uint64
|
||||
Prefix *string
|
||||
Host *string
|
||||
Enabled bool
|
||||
Port uint64
|
||||
Prefix string
|
||||
Host string
|
||||
}
|
||||
|
||||
type GpoConfig struct {
|
||||
Blocks *uint64
|
||||
Percentile *uint64
|
||||
Blocks uint64
|
||||
Percentile uint64
|
||||
MaxPrice *big.Int
|
||||
IgnorePrice *big.Int
|
||||
}
|
||||
|
||||
type MetricsConfig struct {
|
||||
Enabled *bool
|
||||
Expensive *bool
|
||||
Enabled bool
|
||||
Expensive bool
|
||||
InfluxDB *InfluxDBConfig
|
||||
}
|
||||
|
||||
type InfluxDBConfig struct {
|
||||
V1Enabled *bool
|
||||
Endpoint *string
|
||||
Database *string
|
||||
Username *string
|
||||
Password *string
|
||||
Tags *map[string]string
|
||||
V2Enabled *bool
|
||||
Token *string
|
||||
Bucket *string
|
||||
Organization *string
|
||||
V1Enabled bool
|
||||
Endpoint string
|
||||
Database string
|
||||
Username string
|
||||
Password string
|
||||
Tags map[string]string
|
||||
V2Enabled bool
|
||||
Token string
|
||||
Bucket string
|
||||
Organization string
|
||||
}
|
||||
|
||||
type CacheConfig struct {
|
||||
Cache *uint64
|
||||
PercGc *uint64
|
||||
PercSnapshot *uint64
|
||||
PercDatabase *uint64
|
||||
PercTrie *uint64
|
||||
Journal *string
|
||||
Rejournal *time.Duration
|
||||
NoPrefetch *bool
|
||||
Preimages *bool
|
||||
TxLookupLimit *uint64
|
||||
Cache uint64
|
||||
PercGc uint64
|
||||
PercSnapshot uint64
|
||||
PercDatabase uint64
|
||||
PercTrie uint64
|
||||
Journal string
|
||||
Rejournal time.Duration
|
||||
NoPrefetch bool
|
||||
Preimages bool
|
||||
TxLookupLimit uint64
|
||||
}
|
||||
|
||||
type AccountsConfig struct {
|
||||
Unlock []string
|
||||
PasswordFile *string
|
||||
AllowInsecureUnlock *bool
|
||||
UseLightweightKDF *bool
|
||||
PasswordFile string
|
||||
AllowInsecureUnlock bool
|
||||
UseLightweightKDF bool
|
||||
}
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Chain: stringPtr("mainnet"),
|
||||
Debug: boolPtr(false),
|
||||
Whitelist: mapStrPtr(map[string]string{}),
|
||||
LogLevel: stringPtr("INFO"),
|
||||
DataDir: stringPtr(defaultDataDir()),
|
||||
Chain: "mainnet",
|
||||
Debug: false,
|
||||
Whitelist: map[string]string{},
|
||||
LogLevel: "INFO",
|
||||
DataDir: defaultDataDir(),
|
||||
P2P: &P2PConfig{
|
||||
MaxPeers: uint64Ptr(30),
|
||||
MaxPendPeers: uint64Ptr(50),
|
||||
Bind: stringPtr("0.0.0.0"),
|
||||
Port: uint64Ptr(30303),
|
||||
NoDiscover: boolPtr(false),
|
||||
NAT: stringPtr("any"),
|
||||
MaxPeers: 30,
|
||||
MaxPendPeers: 50,
|
||||
Bind: "0.0.0.0",
|
||||
Port: 30303,
|
||||
NoDiscover: false,
|
||||
NAT: "any",
|
||||
Discovery: &P2PDiscovery{
|
||||
V5Enabled: boolPtr(false),
|
||||
V5Enabled: false,
|
||||
Bootnodes: []string{},
|
||||
BootnodesV4: []string{},
|
||||
BootnodesV5: []string{},
|
||||
|
|
@ -219,97 +195,97 @@ func DefaultConfig() *Config {
|
|||
},
|
||||
},
|
||||
Heimdall: &HeimdallConfig{
|
||||
URL: stringPtr("http://localhost:1317"),
|
||||
Without: boolPtr(false),
|
||||
URL: "http://localhost:1317",
|
||||
Without: false,
|
||||
},
|
||||
SyncMode: stringPtr("fast"),
|
||||
GcMode: stringPtr("full"),
|
||||
Snapshot: boolPtr(true),
|
||||
EthStats: stringPtr(""),
|
||||
SyncMode: "fast",
|
||||
GcMode: "full",
|
||||
Snapshot: true,
|
||||
EthStats: "",
|
||||
TxPool: &TxPoolConfig{
|
||||
Locals: []string{},
|
||||
NoLocals: boolPtr(false),
|
||||
Journal: stringPtr(""),
|
||||
Rejournal: durPtr(1 * time.Hour),
|
||||
PriceLimit: uint64Ptr(1),
|
||||
PriceBump: uint64Ptr(10),
|
||||
AccountSlots: uint64Ptr(16),
|
||||
GlobalSlots: uint64Ptr(4096),
|
||||
AccountQueue: uint64Ptr(64),
|
||||
GlobalQueue: uint64Ptr(1024),
|
||||
LifeTime: durPtr(3 * time.Hour),
|
||||
NoLocals: false,
|
||||
Journal: "",
|
||||
Rejournal: time.Duration(1 * time.Hour),
|
||||
PriceLimit: 1,
|
||||
PriceBump: 10,
|
||||
AccountSlots: 16,
|
||||
GlobalSlots: 4096,
|
||||
AccountQueue: 64,
|
||||
GlobalQueue: 1024,
|
||||
LifeTime: time.Duration(3 * time.Hour),
|
||||
},
|
||||
Sealer: &SealerConfig{
|
||||
Enabled: boolPtr(false),
|
||||
Etherbase: stringPtr(""),
|
||||
GasCeil: uint64Ptr(8000000),
|
||||
Enabled: false,
|
||||
Etherbase: "",
|
||||
GasCeil: 8000000,
|
||||
GasPrice: big.NewInt(params.GWei),
|
||||
ExtraData: stringPtr(""),
|
||||
ExtraData: "",
|
||||
},
|
||||
Gpo: &GpoConfig{
|
||||
Blocks: uint64Ptr(20),
|
||||
Percentile: uint64Ptr(60),
|
||||
Blocks: 20,
|
||||
Percentile: 60,
|
||||
MaxPrice: gasprice.DefaultMaxPrice,
|
||||
IgnorePrice: gasprice.DefaultIgnorePrice,
|
||||
},
|
||||
JsonRPC: &JsonRPCConfig{
|
||||
IPCDisable: boolPtr(false),
|
||||
IPCPath: stringPtr(""),
|
||||
IPCDisable: false,
|
||||
IPCPath: "",
|
||||
Modules: []string{"web3", "net"},
|
||||
Cors: []string{"*"},
|
||||
VHost: []string{"*"},
|
||||
GasCap: uint64Ptr(ethconfig.Defaults.RPCGasCap),
|
||||
TxFeeCap: float64Ptr(ethconfig.Defaults.RPCTxFeeCap),
|
||||
GasCap: ethconfig.Defaults.RPCGasCap,
|
||||
TxFeeCap: ethconfig.Defaults.RPCTxFeeCap,
|
||||
Http: &APIConfig{
|
||||
Enabled: boolPtr(false),
|
||||
Port: uint64Ptr(8545),
|
||||
Prefix: stringPtr(""),
|
||||
Host: stringPtr("localhost"),
|
||||
Enabled: false,
|
||||
Port: 8545,
|
||||
Prefix: "",
|
||||
Host: "localhost",
|
||||
},
|
||||
Ws: &APIConfig{
|
||||
Enabled: boolPtr(false),
|
||||
Port: uint64Ptr(8546),
|
||||
Prefix: stringPtr(""),
|
||||
Host: stringPtr("localhost"),
|
||||
Enabled: false,
|
||||
Port: 8546,
|
||||
Prefix: "",
|
||||
Host: "localhost",
|
||||
},
|
||||
Graphql: &APIConfig{
|
||||
Enabled: boolPtr(false),
|
||||
Enabled: false,
|
||||
},
|
||||
},
|
||||
Ethstats: stringPtr(""),
|
||||
Ethstats: "",
|
||||
Metrics: &MetricsConfig{
|
||||
Enabled: boolPtr(false),
|
||||
Expensive: boolPtr(false),
|
||||
Enabled: false,
|
||||
Expensive: false,
|
||||
InfluxDB: &InfluxDBConfig{
|
||||
V1Enabled: boolPtr(false),
|
||||
Endpoint: stringPtr(""),
|
||||
Database: stringPtr(""),
|
||||
Username: stringPtr(""),
|
||||
Password: stringPtr(""),
|
||||
Tags: mapStrPtr(map[string]string{}),
|
||||
V2Enabled: boolPtr(false),
|
||||
Token: stringPtr(""),
|
||||
Bucket: stringPtr(""),
|
||||
Organization: stringPtr(""),
|
||||
V1Enabled: false,
|
||||
Endpoint: "",
|
||||
Database: "",
|
||||
Username: "",
|
||||
Password: "",
|
||||
Tags: map[string]string{},
|
||||
V2Enabled: false,
|
||||
Token: "",
|
||||
Bucket: "",
|
||||
Organization: "",
|
||||
},
|
||||
},
|
||||
Cache: &CacheConfig{
|
||||
Cache: uint64Ptr(1024),
|
||||
PercDatabase: uint64Ptr(50),
|
||||
PercTrie: uint64Ptr(15),
|
||||
PercGc: uint64Ptr(25),
|
||||
PercSnapshot: uint64Ptr(10),
|
||||
Journal: stringPtr("triecache"),
|
||||
Rejournal: durPtr(60 * time.Minute),
|
||||
NoPrefetch: boolPtr(false),
|
||||
Preimages: boolPtr(false),
|
||||
TxLookupLimit: uint64Ptr(2350000),
|
||||
Cache: 1024,
|
||||
PercDatabase: 50,
|
||||
PercTrie: 15,
|
||||
PercGc: 25,
|
||||
PercSnapshot: 10,
|
||||
Journal: "triecache",
|
||||
Rejournal: 60 * time.Minute,
|
||||
NoPrefetch: false,
|
||||
Preimages: false,
|
||||
TxLookupLimit: 2350000,
|
||||
},
|
||||
Accounts: &AccountsConfig{
|
||||
Unlock: []string{},
|
||||
PasswordFile: stringPtr(""),
|
||||
AllowInsecureUnlock: boolPtr(false),
|
||||
UseLightweightKDF: boolPtr(false),
|
||||
PasswordFile: "",
|
||||
AllowInsecureUnlock: false,
|
||||
UseLightweightKDF: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -330,9 +306,9 @@ func readConfigFile(path string) (*Config, error) {
|
|||
}
|
||||
|
||||
func (c *Config) loadChain() error {
|
||||
chain, ok := chains.GetChain(*c.Chain)
|
||||
chain, ok := chains.GetChain(c.Chain)
|
||||
if !ok {
|
||||
return fmt.Errorf("chain '%s' not found", *c.Chain)
|
||||
return fmt.Errorf("chain '%s' not found", c.Chain)
|
||||
}
|
||||
c.chain = chain
|
||||
|
||||
|
|
@ -342,10 +318,10 @@ func (c *Config) loadChain() error {
|
|||
}
|
||||
|
||||
// depending on the chain we have different cache values
|
||||
if *c.Chain != "mainnet" {
|
||||
c.Cache.Cache = uint64Ptr(4096)
|
||||
if c.Chain != "mainnet" {
|
||||
c.Cache.Cache = 4096
|
||||
} else {
|
||||
c.Cache.Cache = uint64Ptr(1024)
|
||||
c.Cache.Cache = 1024
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -358,30 +334,30 @@ func (c *Config) buildEth() (*ethconfig.Config, error) {
|
|||
n := ethconfig.Defaults
|
||||
n.NetworkId = c.chain.NetworkId
|
||||
n.Genesis = c.chain.Genesis
|
||||
n.HeimdallURL = *c.Heimdall.URL
|
||||
n.WithoutHeimdall = *c.Heimdall.Without
|
||||
n.HeimdallURL = c.Heimdall.URL
|
||||
n.WithoutHeimdall = c.Heimdall.Without
|
||||
|
||||
// txpool options
|
||||
{
|
||||
n.TxPool.NoLocals = *c.TxPool.NoLocals
|
||||
n.TxPool.Journal = *c.TxPool.Journal
|
||||
n.TxPool.Rejournal = *c.TxPool.Rejournal
|
||||
n.TxPool.PriceLimit = *c.TxPool.PriceLimit
|
||||
n.TxPool.PriceBump = *c.TxPool.PriceBump
|
||||
n.TxPool.AccountSlots = *c.TxPool.AccountSlots
|
||||
n.TxPool.GlobalSlots = *c.TxPool.GlobalSlots
|
||||
n.TxPool.AccountQueue = *c.TxPool.AccountQueue
|
||||
n.TxPool.GlobalQueue = *c.TxPool.GlobalQueue
|
||||
n.TxPool.Lifetime = *c.TxPool.LifeTime
|
||||
n.TxPool.NoLocals = c.TxPool.NoLocals
|
||||
n.TxPool.Journal = c.TxPool.Journal
|
||||
n.TxPool.Rejournal = c.TxPool.Rejournal
|
||||
n.TxPool.PriceLimit = c.TxPool.PriceLimit
|
||||
n.TxPool.PriceBump = c.TxPool.PriceBump
|
||||
n.TxPool.AccountSlots = c.TxPool.AccountSlots
|
||||
n.TxPool.GlobalSlots = c.TxPool.GlobalSlots
|
||||
n.TxPool.AccountQueue = c.TxPool.AccountQueue
|
||||
n.TxPool.GlobalQueue = c.TxPool.GlobalQueue
|
||||
n.TxPool.Lifetime = c.TxPool.LifeTime
|
||||
}
|
||||
|
||||
// miner options
|
||||
{
|
||||
n.Miner.GasPrice = c.Sealer.GasPrice
|
||||
n.Miner.GasCeil = *c.Sealer.GasCeil
|
||||
n.Miner.ExtraData = []byte(*c.Sealer.ExtraData)
|
||||
n.Miner.GasCeil = c.Sealer.GasCeil
|
||||
n.Miner.ExtraData = []byte(c.Sealer.ExtraData)
|
||||
|
||||
if etherbase := *c.Sealer.Etherbase; etherbase != "" {
|
||||
if etherbase := c.Sealer.Etherbase; etherbase != "" {
|
||||
if !common.IsHexAddress(etherbase) {
|
||||
return nil, fmt.Errorf("etherbase is not an address: %s", etherbase)
|
||||
}
|
||||
|
|
@ -398,7 +374,7 @@ func (c *Config) buildEth() (*ethconfig.Config, error) {
|
|||
// whitelist
|
||||
{
|
||||
n.Whitelist = map[uint64]common.Hash{}
|
||||
for k, v := range *c.Whitelist {
|
||||
for k, v := range c.Whitelist {
|
||||
number, err := strconv.ParseUint(k, 0, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid whitelist block number %s: %v", k, err)
|
||||
|
|
@ -413,9 +389,9 @@ func (c *Config) buildEth() (*ethconfig.Config, error) {
|
|||
|
||||
// cache
|
||||
{
|
||||
cache := *c.Cache.Cache
|
||||
calcPerc := func(val *uint64) int {
|
||||
return int(cache * (*val) / 100)
|
||||
cache := c.Cache.Cache
|
||||
calcPerc := func(val uint64) int {
|
||||
return int(cache * (val) / 100)
|
||||
}
|
||||
|
||||
// Cap the cache allowance
|
||||
|
|
@ -437,28 +413,28 @@ func (c *Config) buildEth() (*ethconfig.Config, error) {
|
|||
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
|
||||
godebug.SetGCPercent(int(gogc))
|
||||
|
||||
n.TrieCleanCacheJournal = *c.Cache.Journal
|
||||
n.TrieCleanCacheRejournal = *c.Cache.Rejournal
|
||||
n.TrieCleanCacheJournal = c.Cache.Journal
|
||||
n.TrieCleanCacheRejournal = c.Cache.Rejournal
|
||||
n.DatabaseCache = calcPerc(c.Cache.PercDatabase)
|
||||
n.SnapshotCache = calcPerc(c.Cache.PercSnapshot)
|
||||
n.TrieCleanCache = calcPerc(c.Cache.PercTrie)
|
||||
n.TrieDirtyCache = calcPerc(c.Cache.PercGc)
|
||||
n.NoPrefetch = *c.Cache.NoPrefetch
|
||||
n.Preimages = *c.Cache.Preimages
|
||||
n.TxLookupLimit = *c.Cache.TxLookupLimit
|
||||
n.NoPrefetch = c.Cache.NoPrefetch
|
||||
n.Preimages = c.Cache.Preimages
|
||||
n.TxLookupLimit = c.Cache.TxLookupLimit
|
||||
}
|
||||
|
||||
n.RPCGasCap = *c.JsonRPC.GasCap
|
||||
n.RPCGasCap = c.JsonRPC.GasCap
|
||||
if n.RPCGasCap != 0 {
|
||||
log.Info("Set global gas cap", "cap", n.RPCGasCap)
|
||||
} else {
|
||||
log.Info("Global gas cap disabled")
|
||||
}
|
||||
n.RPCTxFeeCap = *c.JsonRPC.TxFeeCap
|
||||
n.RPCTxFeeCap = c.JsonRPC.TxFeeCap
|
||||
|
||||
// sync mode. It can either be "fast", "full" or "snap". We disable
|
||||
// for now the "light" mode.
|
||||
switch *c.SyncMode {
|
||||
switch c.SyncMode {
|
||||
case "fast":
|
||||
n.SyncMode = downloader.FastSync
|
||||
case "full":
|
||||
|
|
@ -466,11 +442,11 @@ func (c *Config) buildEth() (*ethconfig.Config, error) {
|
|||
case "snap":
|
||||
n.SyncMode = downloader.SnapSync
|
||||
default:
|
||||
return nil, fmt.Errorf("sync mode '%s' not found", *c.SyncMode)
|
||||
return nil, fmt.Errorf("sync mode '%s' not found", c.SyncMode)
|
||||
}
|
||||
|
||||
// archive mode. It can either be "archive" or "full".
|
||||
switch *c.GcMode {
|
||||
switch c.GcMode {
|
||||
case "full":
|
||||
n.NoPruning = false
|
||||
case "archive":
|
||||
|
|
@ -480,11 +456,11 @@ func (c *Config) buildEth() (*ethconfig.Config, error) {
|
|||
log.Info("Enabling recording of key preimages since archive mode is used")
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("gcmode '%s' not found", *c.GcMode)
|
||||
return nil, fmt.Errorf("gcmode '%s' not found", c.GcMode)
|
||||
}
|
||||
|
||||
// snapshot disable check
|
||||
if *c.Snapshot {
|
||||
if c.Snapshot {
|
||||
if n.SyncMode == downloader.SnapSync {
|
||||
log.Info("Snap sync requested, enabling --snapshot")
|
||||
} else {
|
||||
|
|
@ -506,50 +482,50 @@ var (
|
|||
|
||||
func (c *Config) buildNode() (*node.Config, error) {
|
||||
ipcPath := ""
|
||||
if !*c.JsonRPC.IPCDisable {
|
||||
if !c.JsonRPC.IPCDisable {
|
||||
ipcPath = clientIdentifier + ".ipc"
|
||||
if *c.JsonRPC.IPCPath != "" {
|
||||
ipcPath = *c.JsonRPC.IPCPath
|
||||
if c.JsonRPC.IPCPath != "" {
|
||||
ipcPath = c.JsonRPC.IPCPath
|
||||
}
|
||||
}
|
||||
|
||||
cfg := &node.Config{
|
||||
Name: clientIdentifier,
|
||||
DataDir: *c.DataDir,
|
||||
UseLightweightKDF: *c.Accounts.UseLightweightKDF,
|
||||
InsecureUnlockAllowed: *c.Accounts.AllowInsecureUnlock,
|
||||
DataDir: c.DataDir,
|
||||
UseLightweightKDF: c.Accounts.UseLightweightKDF,
|
||||
InsecureUnlockAllowed: c.Accounts.AllowInsecureUnlock,
|
||||
Version: params.VersionWithCommit(gitCommit, gitDate),
|
||||
IPCPath: ipcPath,
|
||||
P2P: p2p.Config{
|
||||
MaxPeers: int(*c.P2P.MaxPeers),
|
||||
MaxPendingPeers: int(*c.P2P.MaxPendPeers),
|
||||
ListenAddr: *c.P2P.Bind + ":" + strconv.Itoa(int(*c.P2P.Port)),
|
||||
DiscoveryV5: *c.P2P.Discovery.V5Enabled,
|
||||
MaxPeers: int(c.P2P.MaxPeers),
|
||||
MaxPendingPeers: int(c.P2P.MaxPendPeers),
|
||||
ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)),
|
||||
DiscoveryV5: c.P2P.Discovery.V5Enabled,
|
||||
},
|
||||
HTTPModules: c.JsonRPC.Modules,
|
||||
HTTPCors: c.JsonRPC.Cors,
|
||||
HTTPVirtualHosts: c.JsonRPC.VHost,
|
||||
HTTPPathPrefix: *c.JsonRPC.Http.Prefix,
|
||||
HTTPPathPrefix: c.JsonRPC.Http.Prefix,
|
||||
WSModules: c.JsonRPC.Modules,
|
||||
WSOrigins: c.JsonRPC.Cors,
|
||||
WSPathPrefix: *c.JsonRPC.Ws.Prefix,
|
||||
WSPathPrefix: c.JsonRPC.Ws.Prefix,
|
||||
GraphQLCors: c.JsonRPC.Cors,
|
||||
GraphQLVirtualHosts: c.JsonRPC.VHost,
|
||||
}
|
||||
|
||||
// enable jsonrpc endpoints
|
||||
{
|
||||
if *c.JsonRPC.Http.Enabled {
|
||||
cfg.HTTPHost = *c.JsonRPC.Http.Host
|
||||
cfg.HTTPPort = int(*c.JsonRPC.Http.Port)
|
||||
if c.JsonRPC.Http.Enabled {
|
||||
cfg.HTTPHost = c.JsonRPC.Http.Host
|
||||
cfg.HTTPPort = int(c.JsonRPC.Http.Port)
|
||||
}
|
||||
if *c.JsonRPC.Ws.Enabled {
|
||||
cfg.WSHost = *c.JsonRPC.Ws.Host
|
||||
cfg.WSPort = int(*c.JsonRPC.Ws.Port)
|
||||
if c.JsonRPC.Ws.Enabled {
|
||||
cfg.WSHost = c.JsonRPC.Ws.Host
|
||||
cfg.WSPort = int(c.JsonRPC.Ws.Port)
|
||||
}
|
||||
}
|
||||
|
||||
natif, err := nat.Parse(*c.P2P.NAT)
|
||||
natif, err := nat.Parse(c.P2P.NAT)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("wrong 'nat' flag: %v", err)
|
||||
}
|
||||
|
|
@ -574,7 +550,7 @@ func (c *Config) buildNode() (*node.Config, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if *c.P2P.NoDiscover {
|
||||
if c.P2P.NoDiscover {
|
||||
// Disable networking, for now, we will not even allow incomming connections
|
||||
cfg.P2P.MaxPeers = 0
|
||||
cfg.P2P.NoDiscovery = true
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
@ -20,11 +21,14 @@ func TestConfigDefault(t *testing.T) {
|
|||
|
||||
func TestConfigMerge(t *testing.T) {
|
||||
c0 := &Config{
|
||||
Chain: stringPtr("0"),
|
||||
Debug: boolPtr(false),
|
||||
Whitelist: mapStrPtr(map[string]string{
|
||||
Chain: "0",
|
||||
Debug: true,
|
||||
Whitelist: map[string]string{
|
||||
"a": "b",
|
||||
}),
|
||||
},
|
||||
TxPool: &TxPoolConfig{
|
||||
LifeTime: 5 * time.Second,
|
||||
},
|
||||
P2P: &P2PConfig{
|
||||
Discovery: &P2PDiscovery{
|
||||
StaticNodes: []string{
|
||||
|
|
@ -34,11 +38,12 @@ func TestConfigMerge(t *testing.T) {
|
|||
},
|
||||
}
|
||||
c1 := &Config{
|
||||
Chain: stringPtr("1"),
|
||||
Whitelist: mapStrPtr(map[string]string{
|
||||
Chain: "1",
|
||||
Whitelist: map[string]string{
|
||||
"b": "c",
|
||||
}),
|
||||
},
|
||||
P2P: &P2PConfig{
|
||||
MaxPeers: 10,
|
||||
Discovery: &P2PDiscovery{
|
||||
StaticNodes: []string{
|
||||
"b",
|
||||
|
|
@ -47,13 +52,17 @@ func TestConfigMerge(t *testing.T) {
|
|||
},
|
||||
}
|
||||
expected := &Config{
|
||||
Chain: stringPtr("1"),
|
||||
Debug: boolPtr(false),
|
||||
Whitelist: mapStrPtr(map[string]string{
|
||||
Chain: "1",
|
||||
Debug: true,
|
||||
Whitelist: map[string]string{
|
||||
"a": "b",
|
||||
"b": "c",
|
||||
}),
|
||||
},
|
||||
TxPool: &TxPoolConfig{
|
||||
LifeTime: 5 * time.Second,
|
||||
},
|
||||
P2P: &P2PConfig{
|
||||
MaxPeers: 10,
|
||||
Discovery: &P2PDiscovery{
|
||||
StaticNodes: []string{
|
||||
"a",
|
||||
|
|
|
|||
|
|
@ -12,22 +12,22 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "debug",
|
||||
Usage: "Path of the file to apply",
|
||||
Value: c.cliConfig.Debug,
|
||||
Value: &c.cliConfig.Debug,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "chain",
|
||||
Usage: "Name of the chain to sync",
|
||||
Value: c.cliConfig.Chain,
|
||||
Value: &c.cliConfig.Chain,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "log-level",
|
||||
Usage: "Set log level for the server",
|
||||
Value: c.cliConfig.LogLevel,
|
||||
Value: &c.cliConfig.LogLevel,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "datadir",
|
||||
Usage: "Path of the data directory to store information",
|
||||
Value: c.cliConfig.DataDir,
|
||||
Value: &c.cliConfig.DataDir,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "config",
|
||||
|
|
@ -37,34 +37,34 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "syncmode",
|
||||
Usage: `Blockchain sync mode ("fast", "full", "snap" or "light")`,
|
||||
Value: c.cliConfig.SyncMode,
|
||||
Value: &c.cliConfig.SyncMode,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "gcmode",
|
||||
Usage: `Blockchain garbage collection mode ("full", "archive")`,
|
||||
Value: c.cliConfig.GcMode,
|
||||
Value: &c.cliConfig.GcMode,
|
||||
})
|
||||
f.MapStringFlag(&flagset.MapStringFlag{
|
||||
Name: "whitelist",
|
||||
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
|
||||
Value: c.cliConfig.Whitelist,
|
||||
Value: &c.cliConfig.Whitelist,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "snapshot",
|
||||
Usage: `Enables snapshot-database mode (default = enable)`,
|
||||
Value: c.cliConfig.Snapshot,
|
||||
Value: &c.cliConfig.Snapshot,
|
||||
})
|
||||
|
||||
// heimdall
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "bor.heimdall",
|
||||
Usage: "URL of Heimdall service",
|
||||
Value: c.cliConfig.Heimdall.URL,
|
||||
Value: &c.cliConfig.Heimdall.URL,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "bor.withoutheimdall",
|
||||
Usage: "Run without Heimdall service (for testing purpose)",
|
||||
Value: c.cliConfig.Heimdall.Without,
|
||||
Value: &c.cliConfig.Heimdall.Without,
|
||||
})
|
||||
|
||||
// txpool options
|
||||
|
|
@ -76,74 +76,74 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "txpool.nolocals",
|
||||
Usage: "Disables price exemptions for locally submitted transactions",
|
||||
Value: c.cliConfig.TxPool.NoLocals,
|
||||
Value: &c.cliConfig.TxPool.NoLocals,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "txpool.journal",
|
||||
Usage: "Disk journal for local transaction to survive node restarts",
|
||||
Value: c.cliConfig.TxPool.Journal,
|
||||
Value: &c.cliConfig.TxPool.Journal,
|
||||
})
|
||||
f.DurationFlag(&flagset.DurationFlag{
|
||||
Name: "txpool.rejournal",
|
||||
Usage: "Time interval to regenerate the local transaction journal",
|
||||
Value: c.cliConfig.TxPool.Rejournal,
|
||||
Value: &c.cliConfig.TxPool.Rejournal,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "txpool.pricelimit",
|
||||
Usage: "Minimum gas price limit to enforce for acceptance into the pool",
|
||||
Value: c.cliConfig.TxPool.PriceLimit,
|
||||
Value: &c.cliConfig.TxPool.PriceLimit,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "txpool.pricebump",
|
||||
Usage: "Price bump percentage to replace an already existing transaction",
|
||||
Value: c.cliConfig.TxPool.PriceBump,
|
||||
Value: &c.cliConfig.TxPool.PriceBump,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "txpool.accountslots",
|
||||
Usage: "Minimum number of executable transaction slots guaranteed per account",
|
||||
Value: c.cliConfig.TxPool.AccountSlots,
|
||||
Value: &c.cliConfig.TxPool.AccountSlots,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "txpool.globalslots",
|
||||
Usage: "Maximum number of executable transaction slots for all accounts",
|
||||
Value: c.cliConfig.TxPool.GlobalSlots,
|
||||
Value: &c.cliConfig.TxPool.GlobalSlots,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "txpool.accountqueue",
|
||||
Usage: "Maximum number of non-executable transaction slots permitted per account",
|
||||
Value: c.cliConfig.TxPool.AccountQueue,
|
||||
Value: &c.cliConfig.TxPool.AccountQueue,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "txpool.globalqueue",
|
||||
Usage: "Maximum number of non-executable transaction slots for all accounts",
|
||||
Value: c.cliConfig.TxPool.GlobalQueue,
|
||||
Value: &c.cliConfig.TxPool.GlobalQueue,
|
||||
})
|
||||
f.DurationFlag(&flagset.DurationFlag{
|
||||
Name: "txpool.lifetime",
|
||||
Usage: "Maximum amount of time non-executable transaction are queued",
|
||||
Value: c.cliConfig.TxPool.LifeTime,
|
||||
Value: &c.cliConfig.TxPool.LifeTime,
|
||||
})
|
||||
|
||||
// sealer options
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "mine",
|
||||
Usage: "Enable mining",
|
||||
Value: c.cliConfig.Sealer.Enabled,
|
||||
Value: &c.cliConfig.Sealer.Enabled,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "miner.etherbase",
|
||||
Usage: "Public address for block mining rewards (default = first account)",
|
||||
Value: c.cliConfig.Sealer.Etherbase,
|
||||
Value: &c.cliConfig.Sealer.Etherbase,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "miner.extradata",
|
||||
Usage: "Block extra data set by the miner (default = client version)",
|
||||
Value: c.cliConfig.Sealer.ExtraData,
|
||||
Value: &c.cliConfig.Sealer.ExtraData,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "miner.gaslimit",
|
||||
Usage: "Target gas ceiling for mined blocks",
|
||||
Value: c.cliConfig.Sealer.GasCeil,
|
||||
Value: &c.cliConfig.Sealer.GasCeil,
|
||||
})
|
||||
f.BigIntFlag(&flagset.BigIntFlag{
|
||||
Name: "miner.gasprice",
|
||||
|
|
@ -155,19 +155,19 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "ethstats",
|
||||
Usage: "Reporting URL of a ethstats service (nodename:secret@host:port)",
|
||||
Value: c.cliConfig.Ethstats,
|
||||
Value: &c.cliConfig.Ethstats,
|
||||
})
|
||||
|
||||
// gas price oracle
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "gpo.blocks",
|
||||
Usage: "Number of recent blocks to check for gas prices",
|
||||
Value: c.cliConfig.Gpo.Blocks,
|
||||
Value: &c.cliConfig.Gpo.Blocks,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "gpo.percentile",
|
||||
Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices",
|
||||
Value: c.cliConfig.Gpo.Percentile,
|
||||
Value: &c.cliConfig.Gpo.Percentile,
|
||||
})
|
||||
f.BigIntFlag(&flagset.BigIntFlag{
|
||||
Name: "gpo.maxprice",
|
||||
|
|
@ -184,74 +184,74 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "cache",
|
||||
Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node)",
|
||||
Value: c.cliConfig.Cache.Cache,
|
||||
Value: &c.cliConfig.Cache.Cache,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "cache.database",
|
||||
Usage: "Percentage of cache memory allowance to use for database io",
|
||||
Value: c.cliConfig.Cache.PercDatabase,
|
||||
Value: &c.cliConfig.Cache.PercDatabase,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "cache.trie",
|
||||
Usage: "Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)",
|
||||
Value: c.cliConfig.Cache.PercTrie,
|
||||
Value: &c.cliConfig.Cache.PercTrie,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "cache.trie.journal",
|
||||
Usage: "Disk journal directory for trie cache to survive node restarts",
|
||||
Value: c.cliConfig.Cache.Journal,
|
||||
Value: &c.cliConfig.Cache.Journal,
|
||||
})
|
||||
f.DurationFlag(&flagset.DurationFlag{
|
||||
Name: "cache.trie.rejournal",
|
||||
Usage: "Time interval to regenerate the trie cache journal",
|
||||
Value: c.cliConfig.Cache.Rejournal,
|
||||
Value: &c.cliConfig.Cache.Rejournal,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "cache.gc",
|
||||
Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)",
|
||||
Value: c.cliConfig.Cache.PercGc,
|
||||
Value: &c.cliConfig.Cache.PercGc,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "cache.snapshot",
|
||||
Usage: "Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)",
|
||||
Value: c.cliConfig.Cache.PercSnapshot,
|
||||
Value: &c.cliConfig.Cache.PercSnapshot,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "cache.noprefetch",
|
||||
Usage: "Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)",
|
||||
Value: c.cliConfig.Cache.NoPrefetch,
|
||||
Value: &c.cliConfig.Cache.NoPrefetch,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "cache.preimages",
|
||||
Usage: "Enable recording the SHA3/keccak preimages of trie keys",
|
||||
Value: c.cliConfig.Cache.Preimages,
|
||||
Value: &c.cliConfig.Cache.Preimages,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "txlookuplimit",
|
||||
Usage: "Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain)",
|
||||
Value: c.cliConfig.Cache.TxLookupLimit,
|
||||
Value: &c.cliConfig.Cache.TxLookupLimit,
|
||||
})
|
||||
|
||||
// rpc options
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "rpc.gascap",
|
||||
Usage: "Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)",
|
||||
Value: c.cliConfig.JsonRPC.GasCap,
|
||||
Value: &c.cliConfig.JsonRPC.GasCap,
|
||||
})
|
||||
f.Float64Flag(&flagset.Float64Flag{
|
||||
Name: "rpc.txfeecap",
|
||||
Usage: "Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)",
|
||||
Value: c.cliConfig.JsonRPC.TxFeeCap,
|
||||
Value: &c.cliConfig.JsonRPC.TxFeeCap,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "ipcdisable",
|
||||
Usage: "Disable the IPC-RPC server",
|
||||
Value: c.cliConfig.JsonRPC.IPCDisable,
|
||||
Value: &c.cliConfig.JsonRPC.IPCDisable,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "ipcpath",
|
||||
Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
|
||||
Value: c.cliConfig.JsonRPC.IPCPath,
|
||||
Value: &c.cliConfig.JsonRPC.IPCPath,
|
||||
})
|
||||
f.SliceStringFlag(&flagset.SliceStringFlag{
|
||||
Name: "jsonrpc.corsdomain",
|
||||
|
|
@ -264,7 +264,7 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
Value: &c.cliConfig.JsonRPC.VHost,
|
||||
})
|
||||
f.SliceStringFlag(&flagset.SliceStringFlag{
|
||||
Name: "jsonrpc.modules",
|
||||
Name: "jsonrpc.modules",
|
||||
Usage: "API's offered over the HTTP-RPC interface",
|
||||
Value: &c.cliConfig.JsonRPC.Modules,
|
||||
})
|
||||
|
|
@ -273,61 +273,61 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "http",
|
||||
Usage: "Enable the HTTP-RPC server",
|
||||
Value: c.cliConfig.JsonRPC.Http.Enabled,
|
||||
Value: &c.cliConfig.JsonRPC.Http.Enabled,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "http.addr",
|
||||
Usage: "HTTP-RPC server listening interface",
|
||||
Value: c.cliConfig.JsonRPC.Http.Host,
|
||||
Value: &c.cliConfig.JsonRPC.Http.Host,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "http.port",
|
||||
Usage: "HTTP-RPC server listening port",
|
||||
Value: c.cliConfig.JsonRPC.Http.Port,
|
||||
Value: &c.cliConfig.JsonRPC.Http.Port,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "http.rpcprefix",
|
||||
Usage: "HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.",
|
||||
Value: c.cliConfig.JsonRPC.Http.Prefix,
|
||||
Value: &c.cliConfig.JsonRPC.Http.Prefix,
|
||||
})
|
||||
// ws options
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "ws",
|
||||
Usage: "Enable the WS-RPC server",
|
||||
Value: c.cliConfig.JsonRPC.Ws.Enabled,
|
||||
Value: &c.cliConfig.JsonRPC.Ws.Enabled,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "ws.addr",
|
||||
Usage: "WS-RPC server listening interface",
|
||||
Value: c.cliConfig.JsonRPC.Ws.Host,
|
||||
Value: &c.cliConfig.JsonRPC.Ws.Host,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "ws.port",
|
||||
Usage: "WS-RPC server listening port",
|
||||
Value: c.cliConfig.JsonRPC.Ws.Port,
|
||||
Value: &c.cliConfig.JsonRPC.Ws.Port,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "ws.rpcprefix",
|
||||
Usage: "HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.",
|
||||
Value: c.cliConfig.JsonRPC.Ws.Prefix,
|
||||
Value: &c.cliConfig.JsonRPC.Ws.Prefix,
|
||||
})
|
||||
// graphql options
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "graphql",
|
||||
Usage: "Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.",
|
||||
Value: c.cliConfig.JsonRPC.Graphql.Enabled,
|
||||
Value: &c.cliConfig.JsonRPC.Graphql.Enabled,
|
||||
})
|
||||
|
||||
// p2p options
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "bind",
|
||||
Usage: "Network binding address",
|
||||
Value: c.cliConfig.P2P.Bind,
|
||||
Value: &c.cliConfig.P2P.Bind,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "port",
|
||||
Usage: "Network listening port",
|
||||
Value: c.cliConfig.P2P.Port,
|
||||
Value: &c.cliConfig.P2P.Port,
|
||||
})
|
||||
f.SliceStringFlag(&flagset.SliceStringFlag{
|
||||
Name: "bootnodes",
|
||||
|
|
@ -337,90 +337,90 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "maxpeers",
|
||||
Usage: "Maximum number of network peers (network disabled if set to 0)",
|
||||
Value: c.cliConfig.P2P.MaxPeers,
|
||||
Value: &c.cliConfig.P2P.MaxPeers,
|
||||
})
|
||||
f.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "maxpendpeers",
|
||||
Usage: "Maximum number of pending connection attempts (defaults used if set to 0)",
|
||||
Value: c.cliConfig.P2P.MaxPendPeers,
|
||||
Value: &c.cliConfig.P2P.MaxPendPeers,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "nat",
|
||||
Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)",
|
||||
Value: c.cliConfig.P2P.NAT,
|
||||
Value: &c.cliConfig.P2P.NAT,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "nodiscover",
|
||||
Usage: "Disables the peer discovery mechanism (manual peer addition)",
|
||||
Value: c.cliConfig.P2P.NoDiscover,
|
||||
Value: &c.cliConfig.P2P.NoDiscover,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "v5disc",
|
||||
Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism",
|
||||
Value: c.cliConfig.P2P.Discovery.V5Enabled,
|
||||
Value: &c.cliConfig.P2P.Discovery.V5Enabled,
|
||||
})
|
||||
|
||||
// metrics
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "metrics",
|
||||
Usage: "Enable metrics collection and reporting",
|
||||
Value: c.cliConfig.Metrics.Enabled,
|
||||
Value: &c.cliConfig.Metrics.Enabled,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "metrics.expensive",
|
||||
Usage: "Enable expensive metrics collection and reporting",
|
||||
Value: c.cliConfig.Metrics.Expensive,
|
||||
Value: &c.cliConfig.Metrics.Expensive,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "metrics.influxdb",
|
||||
Usage: "Enable metrics export/push to an external InfluxDB database (v1)",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.V1Enabled,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.V1Enabled,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "metrics.influxdb.endpoint",
|
||||
Usage: "InfluxDB API endpoint to report metrics to",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.Endpoint,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.Endpoint,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "metrics.influxdb.database",
|
||||
Usage: "InfluxDB database name to push reported metrics to",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.Database,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.Database,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "metrics.influxdb.username",
|
||||
Usage: "Username to authorize access to the database",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.Username,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.Username,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "metrics.influxdb.password",
|
||||
Usage: "Password to authorize access to the database",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.Password,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.Password,
|
||||
})
|
||||
f.MapStringFlag(&flagset.MapStringFlag{
|
||||
Name: "metrics.influxdb.tags",
|
||||
Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.Tags,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.Tags,
|
||||
})
|
||||
// influx db v2
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "metrics.influxdbv2",
|
||||
Usage: "Enable metrics export/push to an external InfluxDB v2 database",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.V2Enabled,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.V2Enabled,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "metrics.influxdb.token",
|
||||
Usage: "Token to authorize access to the database (v2 only)",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.Token,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.Token,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "metrics.influxdb.bucket",
|
||||
Usage: "InfluxDB bucket name to push reported metrics to (v2 only)",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.Bucket,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.Bucket,
|
||||
})
|
||||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "metrics.influxdb.organization",
|
||||
Usage: "InfluxDB organization name (v2 only)",
|
||||
Value: c.cliConfig.Metrics.InfluxDB.Organization,
|
||||
Value: &c.cliConfig.Metrics.InfluxDB.Organization,
|
||||
})
|
||||
|
||||
// account
|
||||
|
|
@ -432,17 +432,17 @@ func (c *Command) Flags() *flagset.Flagset {
|
|||
f.StringFlag(&flagset.StringFlag{
|
||||
Name: "password",
|
||||
Usage: "Password file to use for non-interactive password input",
|
||||
Value: c.cliConfig.Accounts.PasswordFile,
|
||||
Value: &c.cliConfig.Accounts.PasswordFile,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "allow-insecure-unlock",
|
||||
Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http",
|
||||
Value: c.cliConfig.Accounts.AllowInsecureUnlock,
|
||||
Value: &c.cliConfig.Accounts.AllowInsecureUnlock,
|
||||
})
|
||||
f.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "lightkdf",
|
||||
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
|
||||
Value: c.cliConfig.Accounts.UseLightweightKDF,
|
||||
Value: &c.cliConfig.Accounts.UseLightweightKDF,
|
||||
})
|
||||
|
||||
return f
|
||||
|
|
|
|||
Loading…
Reference in a new issue