github.com/aerth/aquachain@v1.4.1/aqua/config.go (about) 1 // Copyright 2017 The aquachain Authors 2 // This file is part of the aquachain library. 3 // 4 // The aquachain 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 aquachain 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 aquachain library. If not, see <http://www.gnu.org/licenses/>. 16 17 package aqua 18 19 import ( 20 "math/big" 21 "os" 22 "os/user" 23 "path/filepath" 24 "runtime" 25 "time" 26 27 "github.com/aquanetwork/aquachain/aqua/downloader" 28 "github.com/aquanetwork/aquachain/aqua/gasprice" 29 "github.com/aquanetwork/aquachain/common" 30 "github.com/aquanetwork/aquachain/common/hexutil" 31 "github.com/aquanetwork/aquachain/consensus/aquahash" 32 "github.com/aquanetwork/aquachain/core" 33 ) 34 35 // DefaultConfig contains default settings for use on the AquaChain main net. 36 var DefaultConfig = Config{ 37 SyncMode: downloader.FastSync, 38 Aquahash: aquahash.Config{ 39 CacheDir: "aquahash", 40 CachesInMem: 2, 41 CachesOnDisk: 3, 42 DatasetsInMem: 1, 43 DatasetsOnDisk: 2, 44 }, 45 NetworkId: 61717561, 46 LightPeers: 100, 47 DatabaseCache: 768, 48 TrieCache: 256, 49 TrieTimeout: 5 * time.Minute, 50 GasPrice: big.NewInt(100000000), // 0.1 gwei 51 52 TxPool: core.DefaultTxPoolConfig, 53 GPO: gasprice.Config{ 54 Blocks: 20, 55 Percentile: 60, 56 }, 57 } 58 59 func init() { 60 home := os.Getenv("HOME") 61 if home == "" { 62 if user, err := user.Current(); err == nil { 63 home = user.HomeDir 64 } 65 } 66 if runtime.GOOS == "windows" { 67 DefaultConfig.Aquahash.DatasetDir = filepath.Join(home, "AppData", "Aquahash") 68 } else { 69 DefaultConfig.Aquahash.DatasetDir = filepath.Join(home, ".aquahash") 70 } 71 } 72 73 //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go 74 75 type Config struct { 76 // The genesis block, which is inserted if the database is empty. 77 // If nil, the AquaChain main net block is used. 78 Genesis *core.Genesis `toml:",omitempty"` 79 80 // Protocol options 81 NetworkId uint64 // Network ID to use for selecting peers to connect to 82 SyncMode downloader.SyncMode 83 NoPruning bool 84 85 // Light client options 86 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 87 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 88 89 // Database options 90 SkipBcVersionCheck bool `toml:"-"` 91 DatabaseHandles int `toml:"-"` 92 DatabaseCache int 93 TrieCache int 94 TrieTimeout time.Duration 95 96 // Mining-related options 97 Aquabase common.Address `toml:",omitempty"` 98 MinerThreads int `toml:",omitempty"` 99 ExtraData []byte `toml:",omitempty"` 100 GasPrice *big.Int 101 102 // Aquahash options 103 Aquahash aquahash.Config 104 105 // Transaction pool options 106 TxPool core.TxPoolConfig 107 108 // Gas Price Oracle options 109 GPO gasprice.Config 110 111 // Enables tracking of SHA3 preimages in the VM 112 EnablePreimageRecording bool 113 114 // Miscellaneous options 115 DocRoot string `toml:"-"` 116 } 117 118 type configMarshaling struct { 119 ExtraData hexutil.Bytes 120 }