params.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/discv5"
  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. // TestnetGenesis returns the JSON spec to use for the Ethereum test network.
  30. func TestnetGenesis() string {
  31. enc, err := json.Marshal(core.DefaultTestnetGenesisBlock())
  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. // FoundationBootnodes returns the enode URLs of the P2P bootstrap nodes operated
  46. // by the foundation running the V5 discovery protocol.
  47. func FoundationBootnodes() *Enodes {
  48. nodes := &Enodes{nodes: make([]*discv5.Node, len(params.DiscoveryV5Bootnodes))}
  49. for i, url := range params.DiscoveryV5Bootnodes {
  50. nodes.nodes[i] = discv5.MustParseNode(url)
  51. }
  52. return nodes
  53. }