You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

chainparamsbase.cpp 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright (c) 2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2014 The Bitcoin developers
  3. // Distributed under the MIT/X11 software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #include "chainparamsbase.h"
  6. #include "util.h"
  7. #include <assert.h>
  8. #include <boost/assign/list_of.hpp>
  9. using namespace boost::assign;
  10. //
  11. // Main network
  12. //
  13. class CBaseMainParams : public CBaseChainParams {
  14. public:
  15. CBaseMainParams() {
  16. networkID = CBaseChainParams::MAIN;
  17. nRPCPort = 8332;
  18. }
  19. };
  20. static CBaseMainParams mainParams;
  21. //
  22. // Testnet (v3)
  23. //
  24. class CBaseTestNetParams : public CBaseMainParams {
  25. public:
  26. CBaseTestNetParams() {
  27. networkID = CBaseChainParams::TESTNET;
  28. nRPCPort = 18332;
  29. strDataDir = "testnet3";
  30. }
  31. };
  32. static CBaseTestNetParams testNetParams;
  33. //
  34. // Regression test
  35. //
  36. class CBaseRegTestParams : public CBaseTestNetParams {
  37. public:
  38. CBaseRegTestParams() {
  39. networkID = CBaseChainParams::REGTEST;
  40. strDataDir = "regtest";
  41. }
  42. };
  43. static CBaseRegTestParams regTestParams;
  44. static CBaseChainParams *pCurrentBaseParams = 0;
  45. const CBaseChainParams &BaseParams() {
  46. assert(pCurrentBaseParams);
  47. return *pCurrentBaseParams;
  48. }
  49. void SelectBaseParams(CBaseChainParams::Network network) {
  50. switch (network) {
  51. case CBaseChainParams::MAIN:
  52. pCurrentBaseParams = &mainParams;
  53. break;
  54. case CBaseChainParams::TESTNET:
  55. pCurrentBaseParams = &testNetParams;
  56. break;
  57. case CBaseChainParams::REGTEST:
  58. pCurrentBaseParams = &regTestParams;
  59. break;
  60. default:
  61. assert(false && "Unimplemented network");
  62. return;
  63. }
  64. }
  65. bool SelectBaseParamsFromCommandLine() {
  66. bool fRegTest = GetBoolArg("-regtest", false);
  67. bool fTestNet = GetBoolArg("-testnet", false);
  68. if (fTestNet && fRegTest) {
  69. return false;
  70. }
  71. if (fRegTest) {
  72. SelectBaseParams(CBaseChainParams::REGTEST);
  73. } else if (fTestNet) {
  74. SelectBaseParams(CBaseChainParams::TESTNET);
  75. } else {
  76. SelectBaseParams(CBaseChainParams::MAIN);
  77. }
  78. return true;
  79. }
  80. bool AreBaseParamsConfigured() {
  81. return pCurrentBaseParams != NULL;
  82. }