github.com/pfcoder/quorum@v2.0.3-0.20180501191142-d4a1b0958135+incompatible/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  
    26  	"github.com/ethereum/go-ethereum/common"
    27  	"github.com/ethereum/go-ethereum/common/hexutil"
    28  	"github.com/ethereum/go-ethereum/consensus/istanbul"
    29  	"github.com/ethereum/go-ethereum/core"
    30  	"github.com/ethereum/go-ethereum/eth/downloader"
    31  	"github.com/ethereum/go-ethereum/eth/gasprice"
    32  	"github.com/ethereum/go-ethereum/params"
    33  )
    34  
    35  // DefaultConfig contains default settings for use on the Ethereum main net.
    36  var DefaultConfig = Config{
    37  	SyncMode:             downloader.FastSync,
    38  	EthashCacheDir:       "ethash",
    39  	EthashCachesInMem:    2,
    40  	EthashCachesOnDisk:   3,
    41  	EthashDatasetsInMem:  1,
    42  	EthashDatasetsOnDisk: 2,
    43  	NetworkId:            1,
    44  	LightPeers:           20,
    45  	DatabaseCache:        128,
    46  	GasPrice:             big.NewInt(18 * params.Shannon),
    47  
    48  	TxPool: core.DefaultTxPoolConfig,
    49  	GPO: gasprice.Config{
    50  		Blocks:     10,
    51  		Percentile: 50,
    52  	},
    53  
    54  	Istanbul: *istanbul.DefaultConfig,
    55  }
    56  
    57  func init() {
    58  	home := os.Getenv("HOME")
    59  	if home == "" {
    60  		if user, err := user.Current(); err == nil {
    61  			home = user.HomeDir
    62  		}
    63  	}
    64  	if runtime.GOOS == "windows" {
    65  		DefaultConfig.EthashDatasetDir = filepath.Join(home, "AppData", "Ethash")
    66  	} else {
    67  		DefaultConfig.EthashDatasetDir = filepath.Join(home, ".ethash")
    68  	}
    69  }
    70  
    71  //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go
    72  
    73  type Config struct {
    74  	// The genesis block, which is inserted if the database is empty.
    75  	// If nil, the Ethereum main net block is used.
    76  	Genesis *core.Genesis `toml:",omitempty"`
    77  
    78  	// Protocol options
    79  	NetworkId uint64 // Network ID to use for selecting peers to connect to
    80  	SyncMode  downloader.SyncMode
    81  
    82  	// Light client options
    83  	LightServ  int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
    84  	LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
    85  
    86  	// Database options
    87  	SkipBcVersionCheck bool `toml:"-"`
    88  	DatabaseHandles    int  `toml:"-"`
    89  	DatabaseCache      int
    90  
    91  	// Mining-related options
    92  	Etherbase    common.Address `toml:",omitempty"`
    93  	MinerThreads int            `toml:",omitempty"`
    94  	ExtraData    []byte         `toml:",omitempty"`
    95  	GasPrice     *big.Int
    96  
    97  	// Ethash options
    98  	EthashCacheDir       string
    99  	EthashCachesInMem    int
   100  	EthashCachesOnDisk   int
   101  	EthashDatasetDir     string
   102  	EthashDatasetsInMem  int
   103  	EthashDatasetsOnDisk int
   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  	RaftMode             bool
   115  	EnableNodePermission bool
   116  	// Istanbul options
   117  	Istanbul istanbul.Config
   118  
   119  	// Miscellaneous options
   120  	DocRoot   string `toml:"-"`
   121  	PowFake   bool   `toml:"-"`
   122  	PowTest   bool   `toml:"-"`
   123  	PowShared bool   `toml:"-"`
   124  }
   125  
   126  type configMarshaling struct {
   127  	ExtraData hexutil.Bytes
   128  }