github.com/murrekatt/go-ethereum@v1.5.8-0.20170123175102-fc52f2c007fb/mobile/params.go (about)

     1  // Copyright 2016 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  // Contains all the wrappers from the params package.
    18  
    19  package geth
    20  
    21  import (
    22  	"github.com/ethereum/go-ethereum/core"
    23  	"github.com/ethereum/go-ethereum/p2p/discv5"
    24  	"github.com/ethereum/go-ethereum/params"
    25  )
    26  
    27  // MainnetChainConfig returns the chain configurations for the main Ethereum network.
    28  func MainnetChainConfig() *ChainConfig {
    29  	return &ChainConfig{
    30  		ChainID:        params.MainNetChainID.Int64(),
    31  		HomesteadBlock: params.MainNetHomesteadBlock.Int64(),
    32  		DAOForkBlock:   params.MainNetDAOForkBlock.Int64(),
    33  		DAOForkSupport: true,
    34  		EIP150Block:    params.MainNetHomesteadGasRepriceBlock.Int64(),
    35  		EIP150Hash:     Hash{params.MainNetHomesteadGasRepriceHash},
    36  		EIP155Block:    params.MainNetSpuriousDragon.Int64(),
    37  		EIP158Block:    params.MainNetSpuriousDragon.Int64(),
    38  	}
    39  }
    40  
    41  // MainnetGenesis returns the JSON spec to use for the main Ethereum network. It
    42  // is actually empty since that defaults to the hard coded binary genesis block.
    43  func MainnetGenesis() string {
    44  	return ""
    45  }
    46  
    47  // TestnetChainConfig returns the chain configurations for the Ethereum test network.
    48  func TestnetChainConfig() *ChainConfig {
    49  	return &ChainConfig{
    50  		ChainID:        params.TestNetChainID.Int64(),
    51  		HomesteadBlock: params.TestNetHomesteadBlock.Int64(),
    52  		DAOForkBlock:   0,
    53  		DAOForkSupport: false,
    54  		EIP150Block:    params.TestNetHomesteadGasRepriceBlock.Int64(),
    55  		EIP150Hash:     Hash{params.TestNetHomesteadGasRepriceHash},
    56  		EIP155Block:    params.TestNetSpuriousDragon.Int64(),
    57  		EIP158Block:    params.TestNetSpuriousDragon.Int64(),
    58  	}
    59  }
    60  
    61  // TestnetGenesis returns the JSON spec to use for the Ethereum test network.
    62  func TestnetGenesis() string {
    63  	return core.DefaultTestnetGenesisBlock()
    64  }
    65  
    66  // ChainConfig is the core config which determines the blockchain settings.
    67  type ChainConfig struct {
    68  	ChainID        int64 // Chain ID for replay protection
    69  	HomesteadBlock int64 // Homestead switch block
    70  	DAOForkBlock   int64 // TheDAO hard-fork switch block
    71  	DAOForkSupport bool  // Whether the nodes supports or opposes the DAO hard-fork
    72  	EIP150Block    int64 // Homestead gas reprice switch block
    73  	EIP150Hash     Hash  // Homestead gas reprice switch block hash
    74  	EIP155Block    int64 // Replay protection switch block
    75  	EIP158Block    int64 // Empty account pruning switch block
    76  }
    77  
    78  // NewChainConfig creates a new chain configuration that transitions immediately
    79  // to homestead and has no notion of the DAO fork (ideal for a private network).
    80  func NewChainConfig() *ChainConfig {
    81  	return new(ChainConfig)
    82  }
    83  
    84  // FoundationBootnodes returns the enode URLs of the P2P bootstrap nodes operated
    85  // by the foundation running the V5 discovery protocol.
    86  func FoundationBootnodes() *Enodes {
    87  	nodes := &Enodes{nodes: make([]*discv5.Node, len(params.DiscoveryV5Bootnodes))}
    88  	for i, url := range params.DiscoveryV5Bootnodes {
    89  		nodes.nodes[i] = discv5.MustParseNode(url)
    90  	}
    91  	return nodes
    92  }