github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/eth/config.go (about)

     1  // This file is part of the go-sberex library. The go-sberex library is 
     2  // free software: you can redistribute it and/or modify it under the terms 
     3  // of the GNU Lesser General Public License as published by the Free 
     4  // Software Foundation, either version 3 of the License, or (at your option)
     5  // any later version.
     6  //
     7  // The go-sberex library is distributed in the hope that it will be useful, 
     8  // but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
    10  // General Public License <http://www.gnu.org/licenses/> for more details.
    11  
    12  package eth
    13  
    14  import (
    15  	"math/big"
    16  	"os"
    17  	"os/user"
    18  	"path/filepath"
    19  	"runtime"
    20  	"time"
    21  
    22  	"github.com/Sberex/go-sberex/common"
    23  	"github.com/Sberex/go-sberex/common/hexutil"
    24  	"github.com/Sberex/go-sberex/consensus/ethash"
    25  	"github.com/Sberex/go-sberex/core"
    26  	"github.com/Sberex/go-sberex/eth/downloader"
    27  	"github.com/Sberex/go-sberex/eth/gasprice"
    28  	"github.com/Sberex/go-sberex/params"
    29  )
    30  
    31  // DefaultConfig contains default settings for use on the Sberex main net.
    32  var DefaultConfig = Config{
    33  	SyncMode: downloader.FastSync,
    34  	Ethash: ethash.Config{
    35  		CacheDir:       "ethash",
    36  		CachesInMem:    2,
    37  		CachesOnDisk:   3,
    38  		DatasetsInMem:  1,
    39  		DatasetsOnDisk: 2,
    40  	},
    41  	NetworkId:     1,
    42  	LightPeers:    100,
    43  	DatabaseCache: 768,
    44  	TrieCache:     256,
    45  	TrieTimeout:   5 * time.Minute,
    46  	GasPrice:      big.NewInt(18 * params.Serg),
    47  
    48  	TxPool: core.DefaultTxPoolConfig,
    49  	GPO: gasprice.Config{
    50  		Blocks:     20,
    51  		Percentile: 60,
    52  	},
    53  }
    54  
    55  func init() {
    56  	home := os.Getenv("HOME")
    57  	if home == "" {
    58  		if user, err := user.Current(); err == nil {
    59  			home = user.HomeDir
    60  		}
    61  	}
    62  	if runtime.GOOS == "windows" {
    63  		DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Ethash")
    64  	} else {
    65  		DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash")
    66  	}
    67  }
    68  
    69  //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go
    70  
    71  type Config struct {
    72  	// The genesis block, which is inserted if the database is empty.
    73  	// If nil, the Sberex main net block is used.
    74  	Genesis *core.Genesis `toml:",omitempty"`
    75  
    76  	// Protocol options
    77  	NetworkId uint64 // Network ID to use for selecting peers to connect to
    78  	SyncMode  downloader.SyncMode
    79  	NoPruning bool
    80  
    81  	// Light client options
    82  	LightServ  int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
    83  	LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
    84  
    85  	// Database options
    86  	SkipBcVersionCheck bool `toml:"-"`
    87  	DatabaseHandles    int  `toml:"-"`
    88  	DatabaseCache      int
    89  	TrieCache          int
    90  	TrieTimeout        time.Duration
    91  
    92  	// Mining-related options
    93  	Etherbase    common.Address `toml:",omitempty"`
    94  	MinerThreads int            `toml:",omitempty"`
    95  	ExtraData    []byte         `toml:",omitempty"`
    96  	GasPrice     *big.Int
    97  
    98  	// Ethash options
    99  	Ethash ethash.Config
   100  
   101  	// Transaction pool options
   102  	TxPool core.TxPoolConfig
   103  
   104  	// Gas Price Oracle options
   105  	GPO gasprice.Config
   106  
   107  	// Enables tracking of SHA3 preimages in the VM
   108  	EnablePreimageRecording bool
   109  
   110  	// Miscellaneous options
   111  	DocRoot string `toml:"-"`
   112  }
   113  
   114  type configMarshaling struct {
   115  	ExtraData hexutil.Bytes
   116  }