github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/eth/gen_config.go (about)

     1  
     2  //此源码被清华学神尹成大魔王专业翻译分析并修改
     3  //尹成QQ77025077
     4  //尹成微信18510341407
     5  //尹成所在QQ群721929980
     6  //尹成邮箱 yinc13@mails.tsinghua.edu.cn
     7  //尹成毕业于清华大学,微软区块链领域全球最有价值专家
     8  //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
     9  //代码由github.com/fjl/gencodec生成。不要编辑。
    10  
    11  package eth
    12  
    13  import (
    14  	"math/big"
    15  	"time"
    16  
    17  	"github.com/ethereum/go-ethereum/common"
    18  	"github.com/ethereum/go-ethereum/common/hexutil"
    19  	"github.com/ethereum/go-ethereum/consensus/ethash"
    20  	"github.com/ethereum/go-ethereum/core"
    21  	"github.com/ethereum/go-ethereum/eth/downloader"
    22  	"github.com/ethereum/go-ethereum/eth/gasprice"
    23  )
    24  
    25  var _ = (*configMarshaling)(nil)
    26  
    27  //MsHaltOML封为TOML。
    28  func (c Config) MarshalTOML() (interface{}, error) {
    29  	type Config struct {
    30  		Genesis                 *core.Genesis `toml:",omitempty"`
    31  		NetworkId               uint64
    32  		SyncMode                downloader.SyncMode
    33  		NoPruning               bool
    34  		LightServ               int  `toml:",omitempty"`
    35  		LightPeers              int  `toml:",omitempty"`
    36  		SkipBcVersionCheck      bool `toml:"-"`
    37  		DatabaseHandles         int  `toml:"-"`
    38  		DatabaseCache           int
    39  		TrieCache               int
    40  		TrieTimeout             time.Duration
    41  //etherbase common.address`toml:“,omitempty”`
    42  		Validator               common.Address `toml:",omitempty"`
    43  		Coinbase                common.Address `toml:",omitempty"`
    44  		MinerThreads            int            `toml:",omitempty"`
    45  		MinerNotify             []string       `toml:",omitempty"`
    46  		MinerExtraData          hexutil.Bytes  `toml:",omitempty"`
    47  		MinerGasPrice           *big.Int
    48  		MinerRecommit           time.Duration
    49  		Ethash                  ethash.Config
    50  		TxPool                  core.TxPoolConfig
    51  		GPO                     gasprice.Config
    52  		EnablePreimageRecording bool
    53  		DocRoot                 string `toml:"-"`
    54  	}
    55  	var enc Config
    56  	enc.Genesis = c.Genesis
    57  	enc.NetworkId = c.NetworkId
    58  	enc.SyncMode = c.SyncMode
    59  	enc.NoPruning = c.NoPruning
    60  	enc.LightServ = c.LightServ
    61  	enc.LightPeers = c.LightPeers
    62  	enc.SkipBcVersionCheck = c.SkipBcVersionCheck
    63  	enc.DatabaseHandles = c.DatabaseHandles
    64  	enc.DatabaseCache = c.DatabaseCache
    65  	enc.TrieCache = c.TrieCache
    66  	enc.TrieTimeout = c.TrieTimeout
    67  //Enc.EtherBase=C.EtherBase
    68  	enc.Validator = c.Validator
    69  	enc.Coinbase = c.Coinbase
    70  	enc.MinerThreads = c.MinerThreads
    71  	enc.MinerNotify = c.MinerNotify
    72  	enc.MinerExtraData = c.MinerExtraData
    73  	enc.MinerGasPrice = c.MinerGasPrice
    74  	enc.MinerRecommit = c.MinerRecommit
    75  	enc.Ethash = c.Ethash
    76  	enc.TxPool = c.TxPool
    77  	enc.GPO = c.GPO
    78  	enc.EnablePreimageRecording = c.EnablePreimageRecording
    79  	enc.DocRoot = c.DocRoot
    80  	return &enc, nil
    81  }
    82  
    83  //取消标记从Toml取消标记。
    84  func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
    85  	type Config struct {
    86  		Genesis                 *core.Genesis `toml:",omitempty"`
    87  		NetworkId               *uint64
    88  		SyncMode                *downloader.SyncMode
    89  		NoPruning               *bool
    90  		LightServ               *int  `toml:",omitempty"`
    91  		LightPeers              *int  `toml:",omitempty"`
    92  		SkipBcVersionCheck      *bool `toml:"-"`
    93  		DatabaseHandles         *int  `toml:"-"`
    94  		DatabaseCache           *int
    95  		TrieCache               *int
    96  		TrieTimeout             *time.Duration
    97  //etherbase*common.address`toml:“,omitempty”`
    98  		Validator               *common.Address `toml:",omitempty"`
    99  		Coinbase                *common.Address `toml:",omitempty"`
   100  		MinerThreads            *int            `toml:",omitempty"`
   101  		MinerNotify             []string        `toml:",omitempty"`
   102  		MinerExtraData          *hexutil.Bytes  `toml:",omitempty"`
   103  		MinerGasPrice           *big.Int
   104  		MinerRecommit           *time.Duration
   105  		Ethash                  *ethash.Config
   106  		TxPool                  *core.TxPoolConfig
   107  		GPO                     *gasprice.Config
   108  		EnablePreimageRecording *bool
   109  		DocRoot                 *string `toml:"-"`
   110  	}
   111  	var dec Config
   112  	if err := unmarshal(&dec); err != nil {
   113  		return err
   114  	}
   115  	if dec.Genesis != nil {
   116  		c.Genesis = dec.Genesis
   117  	}
   118  	if dec.NetworkId != nil {
   119  		c.NetworkId = *dec.NetworkId
   120  	}
   121  	if dec.SyncMode != nil {
   122  		c.SyncMode = *dec.SyncMode
   123  	}
   124  	if dec.NoPruning != nil {
   125  		c.NoPruning = *dec.NoPruning
   126  	}
   127  	if dec.LightServ != nil {
   128  		c.LightServ = *dec.LightServ
   129  	}
   130  	if dec.LightPeers != nil {
   131  		c.LightPeers = *dec.LightPeers
   132  	}
   133  	if dec.SkipBcVersionCheck != nil {
   134  		c.SkipBcVersionCheck = *dec.SkipBcVersionCheck
   135  	}
   136  	if dec.DatabaseHandles != nil {
   137  		c.DatabaseHandles = *dec.DatabaseHandles
   138  	}
   139  	if dec.DatabaseCache != nil {
   140  		c.DatabaseCache = *dec.DatabaseCache
   141  	}
   142  	if dec.TrieCache != nil {
   143  		c.TrieCache = *dec.TrieCache
   144  	}
   145  	if dec.TrieTimeout != nil {
   146  		c.TrieTimeout = *dec.TrieTimeout
   147  	}
   148   /*
   149   如果是12月以太坊!= nIL{
   150    C.EtherBase=*十二月EtherBase
   151   */
   152  
   153  	if dec.Validator != nil {
   154  		c.Validator = *dec.Validator
   155  	}
   156  	if dec.Coinbase != nil {
   157  		c.Coinbase = *dec.Coinbase
   158  	}
   159  	if dec.MinerThreads != nil {
   160  		c.MinerThreads = *dec.MinerThreads
   161  	}
   162  	if dec.MinerNotify != nil {
   163  		c.MinerNotify = dec.MinerNotify
   164  	}
   165  	if dec.MinerExtraData != nil {
   166  		c.MinerExtraData = *dec.MinerExtraData
   167  	}
   168  	if dec.MinerGasPrice != nil {
   169  		c.MinerGasPrice = dec.MinerGasPrice
   170  	}
   171  	if dec.MinerRecommit != nil {
   172  		c.MinerRecommit = *dec.MinerRecommit
   173  	}
   174  	if dec.Ethash != nil {
   175  		c.Ethash = *dec.Ethash
   176  	}
   177  	if dec.TxPool != nil {
   178  		c.TxPool = *dec.TxPool
   179  	}
   180  	if dec.GPO != nil {
   181  		c.GPO = *dec.GPO
   182  	}
   183  	if dec.EnablePreimageRecording != nil {
   184  		c.EnablePreimageRecording = *dec.EnablePreimageRecording
   185  	}
   186  	if dec.DocRoot != nil {
   187  		c.DocRoot = *dec.DocRoot
   188  	}
   189  	return nil
   190  }