github.com/core-coin/go-core/v2@v2.1.9/xcb/config.go (about) 1 // Copyright 2023 by the Authors 2 // This file is part of the go-core library. 3 // 4 // The go-core library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-core library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-core library. If not, see <http://www.gnu.org/licenses/>. 16 17 package xcb 18 19 import ( 20 "math/big" 21 "os" 22 "os/user" 23 "time" 24 25 "github.com/core-coin/go-core/v2/xcb/energyprice" 26 27 "github.com/core-coin/go-core/v2/consensus/cryptore" 28 29 "github.com/core-coin/go-core/v2/common" 30 "github.com/core-coin/go-core/v2/core" 31 "github.com/core-coin/go-core/v2/miner" 32 "github.com/core-coin/go-core/v2/params" 33 "github.com/core-coin/go-core/v2/xcb/downloader" 34 ) 35 36 // DefaultFullGPOConfig contains default energyprice oracle settings for full node. 37 var DefaultFullGPOConfig = energyprice.Config{ 38 Blocks: 20, 39 Percentile: 60, 40 MaxPrice: energyprice.DefaultMaxPrice, 41 } 42 43 // DefaultLightGPOConfig contains default energyprice oracle settings for light client. 44 var DefaultLightGPOConfig = energyprice.Config{ 45 Blocks: 2, 46 Percentile: 60, 47 MaxPrice: energyprice.DefaultMaxPrice, 48 } 49 50 // DefaultConfig contains default settings for use on the Core main net. 51 var DefaultConfig = Config{ 52 SyncMode: downloader.FullSync, 53 Cryptore: cryptore.Config{}, 54 NetworkId: 1, 55 LightPeers: 100, 56 UltraLightFraction: 75, 57 DatabaseCache: 512, 58 TrieCleanCache: 154, 59 TrieCleanCacheJournal: "triecache", 60 TrieCleanCacheRejournal: 60 * time.Minute, 61 TrieDirtyCache: 256, 62 TrieTimeout: 60 * time.Minute, 63 SnapshotCache: 102, 64 Miner: miner.Config{ 65 EnergyFloor: 12500000, 66 EnergyCeil: 14700000, 67 EnergyPrice: big.NewInt(params.Nucle), 68 Recommit: 3 * time.Second, 69 }, 70 TxPool: core.DefaultTxPoolConfig, 71 GPO: DefaultFullGPOConfig, 72 RPCTxFeeCap: 1, // 1 core 73 } 74 75 func init() { 76 home := os.Getenv("HOME") 77 if home == "" { 78 if user, err := user.Current(); err == nil { 79 home = user.HomeDir 80 } 81 } 82 } 83 84 //go:generate gencodec -type Config -formats toml -out gen_config.go 85 86 type Config struct { 87 // The genesis block, which is inserted if the database is empty. 88 // If nil, the Core main net block is used. 89 Genesis *core.Genesis `toml:",omitempty"` 90 91 // Protocol options 92 NetworkId uint64 // Network ID to use for selecting peers to connect to 93 SyncMode downloader.SyncMode 94 95 // This can be set to list of enrtree:// URLs which will be queried for 96 // for nodes to connect to. 97 UseDNSDiscovery bool 98 DiscoveryURLs []string 99 100 NoPruning bool // Whether to disable pruning and flush everything to disk 101 NoPrefetch bool // Whether to disable prefetching and only load state on demand 102 103 TxLookupLimit uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved. 104 105 // Whitelist of required block number -> hash values to accept 106 Whitelist map[uint64]common.Hash `toml:"-"` 107 108 // Light client options 109 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 110 LightIngress int `toml:",omitempty"` // Incoming bandwidth limit for light servers 111 LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers 112 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 113 LightNoPrune bool `toml:",omitempty"` // Whether to disable light chain pruning 114 115 // Ultra Light client options 116 UltraLightServers []string `toml:",omitempty"` // List of trusted ultra light servers 117 UltraLightFraction int `toml:",omitempty"` // Percentage of trusted servers to accept an announcement 118 UltraLightOnlyAnnounce bool `toml:",omitempty"` // Whether to only announce headers, or also serve them 119 120 // Database options 121 SkipBcVersionCheck bool `toml:"-"` 122 DatabaseHandles int `toml:"-"` 123 DatabaseCache int 124 DatabaseFreezer string 125 126 TrieCleanCache int 127 TrieCleanCacheJournal string `toml:",omitempty"` // Disk journal directory for trie cache to survive node restarts 128 TrieCleanCacheRejournal time.Duration `toml:",omitempty"` // Time interval to regenerate the journal for clean cache 129 TrieDirtyCache int 130 TrieTimeout time.Duration 131 SnapshotCache int 132 Preimages bool 133 134 // Mining options 135 Miner miner.Config 136 137 // Cryptore options 138 Cryptore cryptore.Config 139 140 // Transaction pool options 141 TxPool core.TxPoolConfig 142 143 // Energy Price Oracle options 144 GPO energyprice.Config 145 146 // Enables tracking of SHA3 preimages in the VM 147 EnablePreimageRecording bool 148 149 // Miscellaneous options 150 DocRoot string `toml:"-"` 151 152 // Type of the EWASM interpreter ("" for default) 153 EWASMInterpreter string 154 155 // Type of the CVM interpreter ("" for default) 156 CVMInterpreter string 157 158 // TrustedPeersBroadcasting enables broadcasting blocks to trusted peers and after to all connected peers 159 TrustedPeersBroadcasting bool 160 161 // RPCEnergyCap is the global energy cap for xcb-call variants. 162 RPCEnergyCap uint64 `toml:",omitempty"` 163 164 // RPCTxFeeCap is the global transaction fee(price * energylimit) cap for 165 // send-transction variants. The unit is core. 166 RPCTxFeeCap float64 `toml:",omitempty"` 167 168 // Checkpoint is a hardcoded checkpoint which can be nil. 169 Checkpoint *params.TrustedCheckpoint `toml:",omitempty"` 170 171 // CheckpointOracle is the configuration for checkpoint oracle. 172 CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"` 173 }