Chainparams: Use a regular factory for creating chainparams

This commit is contained in:
Jorge Timón
2015-05-22 03:50:01 +02:00
parent 35da2aeed7
commit f87f3626e3
6 changed files with 58 additions and 39 deletions

View File

@@ -11,6 +11,7 @@
#include "primitives/block.h"
#include "protocol.h"
#include <memory>
#include <vector>
struct CDNSSeedData {
@@ -75,6 +76,7 @@ public:
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
const CCheckpointData& Checkpoints() const { return checkpointData; }
const ChainTxData& TxData() const { return chainTxData; }
void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
protected:
CChainParams() {}
@@ -94,6 +96,13 @@ protected:
ChainTxData chainTxData;
};
/**
* Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
* @returns a CChainParams* of the chosen chain.
* @throws a std::runtime_error if the chain is not supported.
*/
std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain);
/**
* Return the currently selected parameters. This won't change after app
* startup, except for unit tests.
@@ -103,7 +112,7 @@ const CChainParams &Params();
/**
* @returns CChainParams for the given BIP70 chain name.
*/
CChainParams& Params(const std::string& chain);
const CChainParams& Params(const std::string& chain);
/**
* Sets the params returned by Params() to those for the given BIP70 chain name.
@@ -114,6 +123,6 @@ void SelectParams(const std::string& chain);
/**
* Allows modifying the BIP9 regtest parameters.
*/
void UpdateRegtestBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
#endif // BITCOIN_CHAINPARAMS_H