params.go 3.4 KB

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