mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Replace naoina/toml with BurntSushi/toml
This commit is contained in:
parent
c3f13b2a1c
commit
3b12336504
4 changed files with 105 additions and 46 deletions
|
|
@ -17,15 +17,12 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
"github.com/ethereum/go-ethereum/accounts/external"
|
||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||
|
|
@ -44,7 +41,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/naoina/toml"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
|
@ -65,39 +61,17 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
// These settings ensure that TOML keys use the same names as Go struct fields.
|
||||
var tomlSettings = toml.Config{
|
||||
NormFieldName: func(rt reflect.Type, key string) string {
|
||||
return key
|
||||
},
|
||||
FieldToKey: func(rt reflect.Type, field string) string {
|
||||
return field
|
||||
},
|
||||
MissingField: func(rt reflect.Type, field string) error {
|
||||
id := fmt.Sprintf("%s.%s", rt.String(), field)
|
||||
if deprecatedConfigFields[id] {
|
||||
log.Warn(fmt.Sprintf("Config field '%s' is deprecated and won't have any effect.", id))
|
||||
return nil
|
||||
}
|
||||
var link string
|
||||
if unicode.IsUpper(rune(rt.Name()[0])) && rt.PkgPath() != "main" {
|
||||
link = fmt.Sprintf(", see https://godoc.org/%s#%s for available fields", rt.PkgPath(), rt.Name())
|
||||
}
|
||||
return fmt.Errorf("field '%s' is not defined in %s%s", field, rt.String(), link)
|
||||
},
|
||||
}
|
||||
|
||||
var deprecatedConfigFields = map[string]bool{
|
||||
"ethconfig.Config.EVMInterpreter": true,
|
||||
"ethconfig.Config.EWASMInterpreter": true,
|
||||
"ethconfig.Config.TrieCleanCacheJournal": true,
|
||||
"ethconfig.Config.TrieCleanCacheRejournal": true,
|
||||
"ethconfig.Config.LightServ": true,
|
||||
"ethconfig.Config.LightIngress": true,
|
||||
"ethconfig.Config.LightEgress": true,
|
||||
"ethconfig.Config.LightPeers": true,
|
||||
"ethconfig.Config.LightNoPrune": true,
|
||||
"ethconfig.Config.LightNoSyncServe": true,
|
||||
"Eth.EVMInterpreter": true,
|
||||
"Eth.EWASMInterpreter": true,
|
||||
"Eth.TrieCleanCacheJournal": true,
|
||||
"Eth.TrieCleanCacheRejournal": true,
|
||||
"Eth.LightServ": true,
|
||||
"Eth.LightIngress": true,
|
||||
"Eth.LightEgress": true,
|
||||
"Eth.LightPeers": true,
|
||||
"Eth.LightNoPrune": true,
|
||||
"Eth.LightNoSyncServe": true,
|
||||
}
|
||||
|
||||
type ethstatsConfig struct {
|
||||
|
|
@ -112,18 +86,22 @@ type gethConfig struct {
|
|||
}
|
||||
|
||||
func loadConfig(file string, cfg *gethConfig) error {
|
||||
f, err := os.Open(file)
|
||||
metadata, err := toml.DecodeFile(file, cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
err = tomlSettings.NewDecoder(bufio.NewReader(f)).Decode(cfg)
|
||||
// Add file name to errors that have a line number.
|
||||
if _, ok := err.(*toml.LineError); ok {
|
||||
err = errors.New(file + ", " + err.Error())
|
||||
// Check for deprecated fields
|
||||
undecoded := metadata.Undecoded()
|
||||
for id, deprecated := range deprecatedConfigFields {
|
||||
for _, key := range undecoded {
|
||||
if key.String() == id && deprecated {
|
||||
log.Warn(fmt.Sprintf("Config field '%s' is deprecated and won't have any effect.", id))
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func defaultNodeConfig() node.Config {
|
||||
|
|
@ -263,7 +241,7 @@ func dumpConfig(ctx *cli.Context) error {
|
|||
comment += "# Note: this config doesn't contain the genesis block.\n\n"
|
||||
}
|
||||
|
||||
out, err := tomlSettings.Marshal(&cfg)
|
||||
out, err := toml.Marshal(&cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
79
custom-config.toml
Normal file
79
custom-config.toml
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
[Eth]
|
||||
NetworkId = 15003
|
||||
SyncMode = "full"
|
||||
EthDiscoveryURLs = []
|
||||
SnapDiscoveryURLs = []
|
||||
NoPruning = true
|
||||
NoPrefetch = false
|
||||
TxLookupLimit = 2350000
|
||||
TransactionHistory = 2350000
|
||||
StateScheme = "hash"
|
||||
DatabaseCache = 512
|
||||
DatabaseFreezer = ""
|
||||
TrieCleanCache = 256
|
||||
TrieDirtyCache = 256
|
||||
TrieTimeout = 3600000000000
|
||||
SnapshotCache = 0
|
||||
Preimages = false
|
||||
FilterLogCacheSize = 32
|
||||
EnablePreimageRecording = false
|
||||
RPCGasCap = 50000000
|
||||
RPCEVMTimeout = 5000000000
|
||||
RPCTxFeeCap = 0e+00
|
||||
|
||||
[Eth.Miner]
|
||||
GasCeil = 30000000
|
||||
GasPrice = 10000000000
|
||||
Recommit = 999999999000000000
|
||||
NewPayloadTimeout = 2000000000
|
||||
|
||||
[Eth.TxPool]
|
||||
Locals = []
|
||||
NoLocals = true
|
||||
Journal = "transactions.rlp"
|
||||
Rejournal = 3600000000000
|
||||
PriceLimit = 10000000000
|
||||
PriceBump = 10
|
||||
AccountSlots = 16
|
||||
GlobalSlots = 5120
|
||||
AccountQueue = 64
|
||||
GlobalQueue = 1024
|
||||
Lifetime = 3600000000000
|
||||
|
||||
[Eth.BlobPool]
|
||||
Datadir = "blobpool"
|
||||
Datacap = 1
|
||||
PriceBump = 100
|
||||
|
||||
[Eth.GPO]
|
||||
Blocks = 120
|
||||
Percentile = 60
|
||||
MaxHeaderHistory = 1024
|
||||
MaxBlockHistory = 1024
|
||||
MaxPrice = 500000000000
|
||||
IgnorePrice = 2
|
||||
|
||||
[Node]
|
||||
DataDir = ""
|
||||
IPCPath = "geth.ipc"
|
||||
HTTPHost = ""
|
||||
HTTPModules = []
|
||||
WSHost = ""
|
||||
WSModules = []
|
||||
AllowUnprotectedTxs = true
|
||||
|
||||
[Node.P2P]
|
||||
MaxPeers = 100
|
||||
NoDiscovery = false
|
||||
BootstrapNodes = []
|
||||
StaticNodes = []
|
||||
TrustedNodes = []
|
||||
ListenAddr = ""
|
||||
DiscAddr = ""
|
||||
EnableMsgEvents = false
|
||||
|
||||
[Node.HTTPTimeouts]
|
||||
ReadTimeout = 0
|
||||
ReadHeaderTimeout = 0
|
||||
WriteTimeout = 0
|
||||
IdleTimeout = 0
|
||||
2
go.mod
2
go.mod
|
|
@ -51,7 +51,6 @@ require (
|
|||
github.com/kylelemons/godebug v1.1.0
|
||||
github.com/mattn/go-colorable v0.1.13
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
|
||||
github.com/protolambda/bls12-381-util v0.1.0
|
||||
|
|
@ -81,6 +80,7 @@ require (
|
|||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
|
||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||
github.com/DataDog/zstd v1.4.5 // indirect
|
||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -44,6 +44,8 @@ github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0/go.mod h1:+6KLcKIVgx
|
|||
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
|
||||
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
|
||||
|
|
|
|||
Loading…
Reference in a new issue