// Copyright 2017 The go-ethereum Authors // This file is part of the go-ethereum library. // // The go-ethereum library is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // The go-ethereum library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see . // Package ethconfig contains the configuration of the ETH and LES protocols. package ethconfig import ( "math/big" "os" "os/user" "path/filepath" "runtime" "time" "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/hexutil" "github.com/XinFinOrg/XDPoSChain/consensus/ethash" "github.com/XinFinOrg/XDPoSChain/core" "github.com/XinFinOrg/XDPoSChain/core/txpool" "github.com/XinFinOrg/XDPoSChain/eth/downloader" "github.com/XinFinOrg/XDPoSChain/eth/gasprice" "github.com/XinFinOrg/XDPoSChain/params" ) // FullNodeGPO contains default gasprice oracle settings for full node. var FullNodeGPO = gasprice.Config{ Blocks: 20, Percentile: 60, MaxHeaderHistory: 1024, MaxBlockHistory: 1024, MaxPrice: gasprice.DefaultMaxPrice, IgnorePrice: gasprice.DefaultIgnorePrice, } // Defaults contains default settings for use on the Ethereum main net. var Defaults = Config{ SyncMode: downloader.FullSync, Ethash: ethash.Config{ CacheDir: "ethash", CachesInMem: 2, CachesOnDisk: 3, DatasetsInMem: 1, DatasetsOnDisk: 2, }, NetworkId: 0, // enable auto configuration of networkID == chainID LightPeers: 100, DatabaseCache: 768, TrieCache: 256, TrieTimeout: 5 * time.Minute, FilterLogCacheSize: 32, GasPrice: big.NewInt(0.25 * params.Shannon), TxPool: txpool.DefaultConfig, RPCGasCap: 50000000, GPO: FullNodeGPO, RPCTxFeeCap: 1, // 1 ether } func init() { home := os.Getenv("HOME") if home == "" { if user, err := user.Current(); err == nil { home = user.HomeDir } } if runtime.GOOS == "darwin" { Defaults.Ethash.DatasetDir = filepath.Join(home, "Library", "Ethash") } else if runtime.GOOS == "windows" { localappdata := os.Getenv("LOCALAPPDATA") if localappdata != "" { Defaults.Ethash.DatasetDir = filepath.Join(localappdata, "Ethash") } else { Defaults.Ethash.DatasetDir = filepath.Join(home, "AppData", "Local", "Ethash") } } else { Defaults.Ethash.DatasetDir = filepath.Join(home, ".ethash") } } //go:generate go run github.com/fjl/gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go // Config contains configuration options for of the ETH and LES protocols. type Config struct { // The genesis block, which is inserted if the database is empty. // If nil, the Ethereum main net block is used. Genesis *core.Genesis `toml:",omitempty"` // Network ID separates blockchains on the peer-to-peer networking level. When left // zero, the chain ID is used as network ID. NetworkId uint64 SyncMode downloader.SyncMode NoPruning bool // Light client options LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests LightPeers int `toml:",omitempty"` // Maximum number of LES client peers // Database options SkipBcVersionCheck bool `toml:"-"` DatabaseHandles int `toml:"-"` DatabaseCache int TrieCache int TrieTimeout time.Duration // This is the number of blocks for which logs will be cached in the filter system. FilterLogCacheSize int // Mining-related options Etherbase common.Address `toml:",omitempty"` MinerThreads int `toml:",omitempty"` ExtraData []byte `toml:",omitempty"` GasPrice *big.Int // Ethash options Ethash ethash.Config // Transaction pool options TxPool txpool.Config // Gas Price Oracle options GPO gasprice.Config // Enables tracking of SHA3 preimages in the VM EnablePreimageRecording bool // Miscellaneous options DocRoot string `toml:"-"` // RPCGasCap is the global gas cap for eth-call variants. RPCGasCap uint64 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for // send-transction variants. The unit is ether. RPCTxFeeCap float64 } type configMarshaling struct { ExtraData hexutil.Bytes }