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.

chainparams.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2016 The Starwels developers
  3. // Distributed under the MIT software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #ifndef STARWELS_CHAINPARAMS_H
  6. #define STARWELS_CHAINPARAMS_H
  7. #include "chainparamsbase.h"
  8. #include "consensus/params.h"
  9. #include "primitives/block.h"
  10. #include "protocol.h"
  11. #include <memory>
  12. #include <vector>
  13. struct CDNSSeedData {
  14. std::string host;
  15. bool supportsServiceBitsFiltering;
  16. CDNSSeedData(const std::string &strHost, bool supportsServiceBitsFilteringIn) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
  17. };
  18. struct SeedSpec6 {
  19. uint8_t addr[16];
  20. uint16_t port;
  21. };
  22. typedef std::map<int, uint256> MapCheckpoints;
  23. struct CCheckpointData {
  24. MapCheckpoints mapCheckpoints;
  25. };
  26. struct ChainTxData {
  27. int64_t nTime;
  28. int64_t nTxCount;
  29. double dTxRate;
  30. };
  31. /**
  32. * CChainParams defines various tweakable parameters of a given instance of the
  33. * Starwels system. There are three: the main network on which people trade goods
  34. * and services, the public ai which gets reset from time to time and
  35. * a regression test mode which is intended for private networks only. It has
  36. * minimal difficulty to ensure that blocks can be found instantly.
  37. */
  38. class CChainParams
  39. {
  40. public:
  41. enum Base58Type {
  42. PUBKEY_ADDRESS,
  43. SCRIPT_ADDRESS,
  44. SECRET_KEY,
  45. EXT_PUBLIC_KEY,
  46. EXT_SECRET_KEY,
  47. MAX_BASE58_TYPES
  48. };
  49. const Consensus::Params& GetConsensus() const { return consensus; }
  50. const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
  51. int GetDefaultPort() const { return nDefaultPort; }
  52. const CBlock& GenesisBlock() const { return genesis; }
  53. /** Default value for -checkmempool and -checkblockindex argument */
  54. bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
  55. /** Policy: Filter transactions that do not match well-defined patterns */
  56. bool RequireStandard() const { return fRequireStandard; }
  57. uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
  58. /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
  59. bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
  60. /** Return the BIP70 network string (main, test or regtest) */
  61. std::string NetworkIDString() const { return strNetworkID; }
  62. const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
  63. const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
  64. const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
  65. const CCheckpointData& Checkpoints() const { return checkpointData; }
  66. const ChainTxData& TxData() const { return chainTxData; }
  67. void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
  68. protected:
  69. CChainParams() {}
  70. Consensus::Params consensus;
  71. CMessageHeader::MessageStartChars pchMessageStart;
  72. int nDefaultPort;
  73. uint64_t nPruneAfterHeight;
  74. std::vector<CDNSSeedData> vSeeds;
  75. std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
  76. std::string strNetworkID;
  77. CBlock genesis;
  78. std::vector<SeedSpec6> vFixedSeeds;
  79. bool fDefaultConsistencyChecks;
  80. bool fRequireStandard;
  81. bool fMineBlocksOnDemand;
  82. CCheckpointData checkpointData;
  83. ChainTxData chainTxData;
  84. };
  85. /**
  86. * Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
  87. * @returns a CChainParams* of the chosen chain.
  88. * @throws a std::runtime_error if the chain is not supported.
  89. */
  90. std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain);
  91. /**
  92. * Return the currently selected parameters. This won't change after app
  93. * startup, except for unit tests.
  94. */
  95. const CChainParams &Params();
  96. /**
  97. * Sets the params returned by Params() to those for the given BIP70 chain name.
  98. * @throws std::runtime_error when the chain is not supported.
  99. */
  100. void SelectParams(const std::string& chain);
  101. /**
  102. * Allows modifying the Version Bits regtest parameters.
  103. */
  104. void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
  105. #endif // STARWELS_CHAINPARAMS_H