github.com/luckypickle/go-ethereum-vet@v1.14.2/eth/config.go (about)

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