github.com/intfoundation/intchain@v0.0.0-20220727031208-4316ad31ca73/intprotocol/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 intprotocol
    18  
    19  import (
    20  	"math/big"
    21  	"os"
    22  	"os/user"
    23  	//"path/filepath"
    24  	"runtime"
    25  	"time"
    26  
    27  	"github.com/intfoundation/intchain/common"
    28  	"github.com/intfoundation/intchain/common/hexutil"
    29  	"github.com/intfoundation/intchain/consensus/ipbft"
    30  	"github.com/intfoundation/intchain/core"
    31  	"github.com/intfoundation/intchain/intprotocol/downloader"
    32  	"github.com/intfoundation/intchain/intprotocol/gasprice"
    33  	"github.com/intfoundation/intchain/params"
    34  )
    35  
    36  // DefaultConfig contains default settings for use on the INT Chain main net.
    37  var DefaultConfig = Config{
    38  	//SyncMode: downloader.FastSync,
    39  	SyncMode:       downloader.FullSync,
    40  	NetworkId:      2047,
    41  	DatabaseCache:  768,
    42  	TrieCleanCache: 256,
    43  	TrieDirtyCache: 256,
    44  	TrieTimeout:    60 * time.Minute,
    45  	MinerGasFloor:  100000000,
    46  	MinerGasCeil:   100000000,
    47  	MinerGasPrice:  big.NewInt(5000 * params.GWei),
    48  
    49  	TxPool: core.DefaultTxPoolConfig,
    50  	GPO: gasprice.Config{
    51  		Blocks:     20,
    52  		Percentile: 60,
    53  	},
    54  }
    55  
    56  func init() {
    57  	home := os.Getenv("HOME")
    58  	if home == "" {
    59  		if user, err := user.Current(); err == nil {
    60  			home = user.HomeDir
    61  		}
    62  	}
    63  	if runtime.GOOS == "windows" {
    64  		//DefaultConfig.DatasetDir = filepath.Join(home, "AppData", "Ethash")
    65  	} else {
    66  		//DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash")
    67  	}
    68  }
    69  
    70  //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go
    71  
    72  type Config struct {
    73  	// The genesis block, which is inserted if the database is empty.
    74  	// If nil, the Ethereum main net block is used.
    75  	Genesis *core.Genesis `toml:",omitempty"`
    76  
    77  	// Protocol options
    78  	NetworkId uint64 // Network ID to use for selecting peers to connect to
    79  	SyncMode  downloader.SyncMode
    80  
    81  	NoPruning bool // Whether to disable pruning and flush everything to disk
    82  
    83  	// Database options
    84  	SkipBcVersionCheck bool `toml:"-"`
    85  	DatabaseHandles    int  `toml:"-"`
    86  	DatabaseCache      int
    87  
    88  	TrieCleanCache int
    89  	TrieDirtyCache int
    90  	TrieTimeout    time.Duration
    91  
    92  	// Mining-related options
    93  	Coinbase      common.Address `toml:",omitempty"`
    94  	ExtraData     []byte         `toml:",omitempty"`
    95  	MinerGasFloor uint64
    96  	MinerGasCeil  uint64
    97  	MinerGasPrice *big.Int
    98  
    99  	// Solidity compiler path
   100  	SolcPath string
   101  
   102  	// Transaction pool options
   103  	TxPool core.TxPoolConfig
   104  
   105  	// Gas Price Oracle options
   106  	GPO gasprice.Config
   107  
   108  	// Enables tracking of SHA3 preimages in the VM
   109  	EnablePreimageRecording bool
   110  
   111  	// Tendermint options
   112  	IPBFT ipbft.Config
   113  
   114  	// Miscellaneous options
   115  	DocRoot string `toml:"-"`
   116  
   117  	// Data Reduction options
   118  	PruneStateData bool
   119  	PruneBlockData bool
   120  }
   121  
   122  type configMarshaling struct {
   123  	ExtraData hexutil.Bytes
   124  }