139 lines
3.2 KiB
C++
139 lines
3.2 KiB
C++
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (c) 2010 Satoshi Nakamoto
|
|
* Copyright (c) 2009-2015 The Bitcoin Core developers
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "chainparamsbase.h"
|
|
#include "tinyformat.h"
|
|
|
|
#include <cassert>
|
|
#include <stdexcept>
|
|
|
|
const std::string CBaseChainParams::MAIN = "main";
|
|
const std::string CBaseChainParams::TESTNET = "test";
|
|
const std::string CBaseChainParams::TESTNET4 = "test4";
|
|
const std::string CBaseChainParams::SCALENET = "scale";
|
|
const std::string CBaseChainParams::REGTEST = "regtest";
|
|
|
|
/**
|
|
* Main network
|
|
*/
|
|
class CBaseMainParams : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseMainParams()
|
|
{
|
|
nRPCPort = 8332;
|
|
nApiServerPort = 1235;
|
|
}
|
|
};
|
|
static CBaseMainParams mainParams;
|
|
|
|
/**
|
|
* Testnet (v3)
|
|
*/
|
|
class CBaseTestNetParams : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseTestNetParams()
|
|
{
|
|
nRPCPort = 18332;
|
|
nApiServerPort = 11235;
|
|
strDataDir = "testnet3";
|
|
}
|
|
};
|
|
static CBaseTestNetParams testNetParams;
|
|
|
|
/**
|
|
* Testnet (v4)
|
|
*/
|
|
class CBaseTestNet4Params : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseTestNet4Params()
|
|
{
|
|
nRPCPort = 28332;
|
|
nApiServerPort = 21235;
|
|
strDataDir = "testnet4";
|
|
}
|
|
};
|
|
static CBaseTestNet4Params testNet4Params;
|
|
|
|
/**
|
|
* Scaling Network
|
|
*/
|
|
class CBaseScaleNetParams : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseScaleNetParams()
|
|
{
|
|
nRPCPort = 38332;
|
|
nApiServerPort = 31235;
|
|
strDataDir = "scalenet";
|
|
}
|
|
};
|
|
static CBaseScaleNetParams scaleNetParams;
|
|
|
|
/*
|
|
* Regression test
|
|
*/
|
|
class CBaseRegTestParams : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseRegTestParams()
|
|
{
|
|
nRPCPort = 18332;
|
|
nApiServerPort = 11235;
|
|
strDataDir = "regtest";
|
|
}
|
|
};
|
|
static CBaseRegTestParams regTestParams;
|
|
|
|
static CBaseChainParams* pCurrentBaseParams = nullptr;
|
|
|
|
const CBaseChainParams& BaseParams()
|
|
{
|
|
assert(pCurrentBaseParams);
|
|
return *pCurrentBaseParams;
|
|
}
|
|
|
|
CBaseChainParams& BaseParams(const std::string& chain)
|
|
{
|
|
if (chain == CBaseChainParams::MAIN)
|
|
return mainParams;
|
|
else if (chain == CBaseChainParams::TESTNET)
|
|
return testNetParams;
|
|
else if (chain == CBaseChainParams::TESTNET4)
|
|
return testNet4Params;
|
|
else if (chain == CBaseChainParams::SCALENET)
|
|
return scaleNetParams;
|
|
else if (chain == CBaseChainParams::REGTEST)
|
|
return regTestParams;
|
|
else
|
|
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
|
}
|
|
|
|
void SelectBaseParams(const std::string& chain)
|
|
{
|
|
pCurrentBaseParams = &BaseParams(chain);
|
|
}
|
|
|
|
bool AreBaseParamsConfigured()
|
|
{
|
|
return pCurrentBaseParams != nullptr;
|
|
}
|