params.go 3.6 KB

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