github.com/aaa256/atlantis@v0.0.0-20210707112435-42ee889287a2/eth/config.go (about)

     1  // Copyright 2017 The go-athereum Authors
     2  // This file is part of the go-athereum library.
     3  //
     4  // The go-athereum 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-athereum 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-athereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package ath
    18  
    19  import (
    20  	"math/big"
    21  	"os"
    22  	"os/user"
    23  	"path/filepath"
    24  	"runtime"
    25  	"time"
    26  
    27  	"github.com/athereum/go-athereum/common"
    28  	"github.com/athereum/go-athereum/common/hexutil"
    29  	"github.com/athereum/go-athereum/consensus/athash"
    30  	"github.com/athereum/go-athereum/core"
    31  	"github.com/athereum/go-athereum/ath/downloader"
    32  	"github.com/athereum/go-athereum/ath/gasprice"
    33  	"github.com/athereum/go-athereum/params"
    34  )
    35  
    36  // DefaultConfig contains default settings for use on the Atlantis main net.
    37  var DefaultConfig = Config{
    38  	SyncMode: downloader.FastSync,
    39  	Ethash: athash.Config{
    40  		CacheDir:       "athash",
    41  		CachesInMem:    2,
    42  		CachesOnDisk:   3,
    43  		DatasetsInMem:  1,
    44  		DatasetsOnDisk: 2,
    45  	},
    46  	NetworkId:     10000,
    47  	LightPeers:    100,
    48  	DatabaseCache: 768,
    49  	TrieCache:     256,
    50  	TrieTimeout:   60 * time.Minute,
    51  	GasPrice:      big.NewInt(18 * params.Shannon),
    52  
    53  	TxPool: core.DefaultTxPoolConfig,
    54  	GPO: gasprice.Config{
    55  		Blocks:     20,
    56  		Percentile: 60,
    57  	},
    58  }
    59  
    60  func init() {
    61  	//home := os.Getenv("HOME")
    62  	home, err := filepath.Abs(filepath.Dir(os.Args[0]))
    63  	if home == "" || err != nil {
    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, "atlantisdata", "Ethash")
    70  	} else {
    71  		DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "atlantisdata",".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 Atlantis 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  	Atlantisbase    common.Address `toml:",omitempty"`
   100  	MinerThreads int            `toml:",omitempty"`
   101  	ExtraData    []byte         `toml:",omitempty"`
   102  	GasPrice     *big.Int
   103  
   104  	// Ethash options
   105  	Ethash athash.Config
   106  
   107  	// Transaction pool options
   108  	TxPool core.TxPoolConfig
   109  
   110  	// Gas Price Oracle options
   111  	GPO gasprice.Config
   112  
   113  	// Enables tracking of SHA3 preimages in the VM
   114  	EnablePreimageRecording bool
   115  
   116  	// Miscellaneous options
   117  	DocRoot string `toml:"-"`
   118  }
   119  
   120  type configMarshaling struct {
   121  	ExtraData hexutil.Bytes
   122  }