params.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. "encoding/json"
  20. "github.com/ethereum/go-ethereum/core"
  21. "github.com/ethereum/go-ethereum/p2p/enode"
  22. "github.com/ethereum/go-ethereum/params"
  23. )
  24. // MainnetGenesis returns the JSON spec to use for the main Ethereum network. It
  25. // is actually empty since that defaults to the hard coded binary genesis block.
  26. func MainnetGenesis() string {
  27. return ""
  28. }
  29. // RopstenGenesis returns the JSON spec to use for the Ropsten test network.
  30. func RopstenGenesis() string {
  31. enc, err := json.Marshal(core.DefaultRopstenGenesisBlock())
  32. if err != nil {
  33. panic(err)
  34. }
  35. return string(enc)
  36. }
  37. // RinkebyGenesis returns the JSON spec to use for the Rinkeby test network
  38. func RinkebyGenesis() string {
  39. enc, err := json.Marshal(core.DefaultRinkebyGenesisBlock())
  40. if err != nil {
  41. panic(err)
  42. }
  43. return string(enc)
  44. }
  45. // GoerliGenesis returns the JSON spec to use for the Goerli test network
  46. func GoerliGenesis() string {
  47. enc, err := json.Marshal(core.DefaultGoerliGenesisBlock())
  48. if err != nil {
  49. panic(err)
  50. }
  51. return string(enc)
  52. }
  53. // FoundationBootnodes returns the enode URLs of the P2P bootstrap nodes operated
  54. // by the foundation running the V5 discovery protocol.
  55. func FoundationBootnodes() *Enodes {
  56. nodes := &Enodes{nodes: make([]*enode.Node, len(params.MainnetBootnodes))}
  57. for i, url := range params.MainnetBootnodes {
  58. var err error
  59. nodes.nodes[i], err = enode.Parse(enode.ValidSchemes, url)
  60. if err != nil {
  61. panic("invalid node URL: " + err.Error())
  62. }
  63. }
  64. return nodes
  65. }