github.com/n1ghtfa1l/go-vnt@v0.6.4-alpha.6/vnt/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 vnt
    18  
    19  import (
    20  	"math/big"
    21  	"os"
    22  	"os/user"
    23  	"time"
    24  
    25  	"github.com/vntchain/go-vnt/common"
    26  	"github.com/vntchain/go-vnt/common/hexutil"
    27  	"github.com/vntchain/go-vnt/core"
    28  	"github.com/vntchain/go-vnt/params"
    29  	"github.com/vntchain/go-vnt/vnt/downloader"
    30  	"github.com/vntchain/go-vnt/vnt/gasprice"
    31  )
    32  
    33  // DefaultConfig contains default settings for use on the VNT main net.
    34  var DefaultConfig = Config{
    35  	SyncMode:      downloader.FullSync,
    36  	NetworkId:     1,
    37  	LightPeers:    100,
    38  	DatabaseCache: 768,
    39  	TrieCache:     256,
    40  	TrieTimeout:   300 * time.Millisecond, // 只计算写区块的时间,写区块的300ms大约等于连续产生了1小时的区块
    41  	GasPrice:      big.NewInt(18 * params.Gwei),
    42  
    43  	TxPool: core.DefaultTxPoolConfig,
    44  	GPO: gasprice.Config{
    45  		Blocks:     20,
    46  		Percentile: 60,
    47  	},
    48  }
    49  
    50  func init() {
    51  	home := os.Getenv("HOME")
    52  	if home == "" {
    53  		if user, err := user.Current(); err == nil {
    54  			home = user.HomeDir
    55  		}
    56  	}
    57  }
    58  
    59  //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go
    60  
    61  type Config struct {
    62  	// The genesis block, which is inserted if the database is empty.
    63  	// If nil, the VNT main net block is used.
    64  	Genesis *core.Genesis `toml:",omitempty"`
    65  
    66  	// Protocol options
    67  	NetworkId uint64 // Network ID to use for selecting peers to connect to
    68  	SyncMode  downloader.SyncMode
    69  	NoPruning bool
    70  
    71  	// Light client options
    72  	LightServ  int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
    73  	LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
    74  
    75  	// Database options
    76  	SkipBcVersionCheck bool `toml:"-"`
    77  	DatabaseHandles    int  `toml:"-"`
    78  	DatabaseCache      int
    79  	TrieCache          int
    80  	TrieTimeout        time.Duration
    81  
    82  	// Producing-related options
    83  	Coinbase  common.Address `toml:",omitempty"`
    84  	ExtraData []byte         `toml:",omitempty"`
    85  	GasPrice  *big.Int
    86  
    87  	// Transaction pool options
    88  	TxPool core.TxPoolConfig
    89  
    90  	// Gas Price Oracle options
    91  	GPO gasprice.Config
    92  
    93  	// Enables tracking of SHA3 preimages in the VM
    94  	EnablePreimageRecording bool
    95  
    96  	// Miscellaneous options
    97  	DocRoot string `toml:"-"`
    98  }
    99  
   100  type configMarshaling struct {
   101  	ExtraData hexutil.Bytes
   102  }