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

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