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.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2014-2017 The Starwels developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #ifndef STARWELS_CHAINPARAMSBASE_H
  5. #define STARWELS_CHAINPARAMSBASE_H
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. /**
  10. * CBaseChainParams defines the base parameters (shared between starwels-cli and starwelsd)
  11. * of a given instance of the Starwels system.
  12. */
  13. class CBaseChainParams
  14. {
  15. public:
  16. /** BIP70 chain name strings (main, test or regtest) */
  17. static const std::string MAIN;
  18. static const std::string AI;
  19. static const std::string REGTEST;
  20. const std::string& DataDir() const { return strDataDir; }
  21. int RPCPort() const { return nRPCPort; }
  22. protected:
  23. CBaseChainParams() {}
  24. int nRPCPort;
  25. std::string strDataDir;
  26. };
  27. /**
  28. * Creates and returns a std::unique_ptr<CBaseChainParams> of the chosen chain.
  29. * @returns a CBaseChainParams* of the chosen chain.
  30. * @throws a std::runtime_error if the chain is not supported.
  31. */
  32. std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain);
  33. /**
  34. * Append the help messages for the chainparams options to the
  35. * parameter string.
  36. */
  37. void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp=true);
  38. /**
  39. * Return the currently selected parameters. This won't change after app
  40. * startup, except for unit tests.
  41. */
  42. const CBaseChainParams& BaseParams();
  43. /** Sets the params returned by Params() to those for the given network. */
  44. void SelectBaseParams(const std::string& chain);
  45. /**
  46. * Looks for -regtest, -ai and returns the appropriate BIP70 chain name.
  47. * @return CBaseChainParams::MAX_NETWORK_TYPES if an invalid combination is given. CBaseChainParams::MAIN by default.
  48. */
  49. std::string ChainNameFromCommandLine();
  50. #endif // STARWELS_CHAINPARAMSBASE_H