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