Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,26 @@ const CBaseChainParams& BaseParams()
return *pCurrentBaseParams;
}

void SelectBaseParams(CBaseChainParams::Network network)
CBaseChainParams& BaseParams(CBaseChainParams::Network network)
{
switch (network) {
case CBaseChainParams::MAIN:
pCurrentBaseParams = &mainParams;
break;
return mainParams;
case CBaseChainParams::TESTNET:
pCurrentBaseParams = &testNetParams;
break;
return testNetParams;
case CBaseChainParams::REGTEST:
pCurrentBaseParams = &regTestParams;
break;
return regTestParams;
default:
assert(false && "Unimplemented network");
return;
return mainParams;
}
}

void SelectBaseParams(CBaseChainParams::Network network)
{
pCurrentBaseParams = &BaseParams(network);
}

CBaseChainParams::Network NetworkIdFromCommandLine()
{
bool fRegTest = GetBoolArg("-regtest", false);
Expand Down
5 changes: 5 additions & 0 deletions src/chainparamsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class CBaseChainParams
*/
const CBaseChainParams& BaseParams();

/**
* Return parameters for the given network.
*/
CBaseChainParams& BaseParams(CBaseChainParams::Network network);

/** Sets the params returned by Params() to those for the given network. */
void SelectBaseParams(CBaseChainParams::Network network);

Expand Down
421 changes: 77 additions & 344 deletions src/init.cpp

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace boost
class thread_group;
} // namespace boost

extern CzPIVWallet* zwalletMain;

void StartShutdown();
bool ShutdownRequested();
/** Interrupt threads */
Expand Down
13 changes: 6 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ int nScriptCheckThreads = 0;
std::atomic<bool> fImporting{false};
std::atomic<bool> fReindex{false};
bool fTxIndex = true;
bool fIsBareMultisigStd = true;
bool fCheckBlockIndex = false;
bool fVerifyingBlocks = false;
size_t nCoinCacheUsage = 5000 * 300;
Expand Down Expand Up @@ -1030,7 +1029,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
strprintf("%d < %d", nFees, txMinFee));

// Require that free transactions have sufficient priority to be mined in the next block.
if (!hasZcSpendInputs && GetBoolArg("-relaypriority", true) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(entry.GetPriority(chainHeight + 1))) {
if (!hasZcSpendInputs && GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(entry.GetPriority(chainHeight + 1))) {
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority");
}

Expand All @@ -1050,7 +1049,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
nLastTime = nNow;
// -limitfreerelay unit is thousand-bytes-per-minute
// At default rate it would take over a month to fill 1GB
if (dFreeCount >= GetArg("-limitfreerelay", 30) * 10 * 1000)
if (dFreeCount >= GetArg("-limitfreerelay", DEFAULT_LIMITFREERELAY) * 10 * 1000)
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "rate limited free transaction");
LogPrint(BCLog::MEMPOOL, "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount + nSize);
dFreeCount += nSize;
Expand Down Expand Up @@ -1282,7 +1281,7 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact
if (mempoolRejectFee > 0 && nFees < mempoolRejectFee) {
return state.DoS(0, error("%s : insuffiecient fee: %d < %d",
__func__, nFees, mempoolRejectFee), REJECT_INSUFFICIENTFEE, "mempool min fee not met", false);
} else if (GetBoolArg("-relaypriority", true) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(entry.GetPriority(chainActive.Height() + 1))) {
} else if (GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nFees < ::minRelayTxFee.GetFee(nSize) && !AllowFree(entry.GetPriority(chainActive.Height() + 1))) {
// Require that free transactions have sufficient priority to be mined in the next block.
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority");
}
Expand All @@ -1303,7 +1302,7 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact
nLastTime = nNow;
// -limitfreerelay unit is thousand-bytes-per-minute
// At default rate it would take over a month to fill 1GB
if (dFreeCount >= GetArg("-limitfreerelay", 30) * 10 * 1000)
if (dFreeCount >= GetArg("-limitfreerelay", DEFAULT_LIMITFREERELAY) * 10 * 1000)
return state.DoS(0, error("AcceptableInputs : free transaction rejected by rate limiter"),
REJECT_INSUFFICIENTFEE, "rate limited free transaction");
LogPrint(BCLog::MEMPOOL, "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount + nSize);
Expand Down Expand Up @@ -1699,7 +1698,7 @@ void Misbehaving(NodeId pnode, int howmuch) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
return;

state->nMisbehavior += howmuch;
int banscore = GetArg("-banscore", 100);
int banscore = GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD);
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore) {
LogPrintf("Misbehaving: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", state->name, state->nMisbehavior - howmuch, state->nMisbehavior);
state->fShouldBan = true;
Expand Down Expand Up @@ -4870,7 +4869,7 @@ std::string GetWarnings(std::string strFor)
if (!CLIENT_VERSION_IS_RELEASE)
strStatusBar = _("This is a pre-release test build - use at your own risk - do not use for staking or merchant applications!");

if (GetBoolArg("-testsafemode", false))
if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
strStatusBar = strRPC = "testsafemode enabled";

// Misc warnings like out of disk space and clock is wrong
Expand Down
14 changes: 13 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,30 @@ struct CNodeStateStats;
static const unsigned int DEFAULT_ANCESTOR_LIMIT = 25;
/** Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors */
static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101;
/** Default for -banscore */
static const int DEFAULT_BANSCORE_THRESHOLD = 100;
/** Default for -limitdescendantcount, max number of in-mempool descendants */
static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25;
/** Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants */
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101;
/** Default for -mempoolexpiry, expiration time for mempool transactions in hours */
static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 72;
/** Default for -txindex */
static const bool DEFAULT_TXINDEX = true;
static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
/** Default for -testsafemode */
static const bool DEFAULT_TESTSAFEMODE = false;
/** Default for -relaypriority */
static const bool DEFAULT_RELAYPRIORITY = true;
/** Default for -limitfeerelay */
static const unsigned int DEFAULT_LIMITFREERELAY = 30;
/** The maximum size for transactions we're willing to relay/mine */
static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
static const unsigned int MAX_ZEROCOIN_TX_SIZE = 150000;
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
/** Default for -checkblocks */
static const signed int DEFAULT_CHECKBLOCKS = 10;
/** The maximum size of a blk?????.dat file (since 0.8) */
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */
Expand Down Expand Up @@ -149,7 +162,6 @@ extern std::atomic<bool> fImporting;
extern std::atomic<bool> fReindex;
extern int nScriptCheckThreads;
extern bool fTxIndex;
extern bool fIsBareMultisigStd;
extern bool fCheckBlockIndex;
extern size_t nCoinCacheUsage;
extern CFeeRate minRelayTxFee;
Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
// Priority order to process transactions
std::list<COrphan> vOrphan; // list memory doesn't move
std::map<uint256, std::vector<COrphan*> > mapDependers;
bool fPrintPriority = GetBoolArg("-printpriority", false);
bool fPrintPriority = GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);

// This vector will be sorted into a priority queue:
std::vector<TxPriority> vecPriority;
Expand Down
2 changes: 2 additions & 0 deletions src/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class CReserveKey;
class CScript;
class CWallet;

static const bool DEFAULT_PRINTPRIORITY = false;

struct CBlockTemplate;

/** Generate a new block, without valid proof-of-work */
Expand Down
8 changes: 4 additions & 4 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ void CNode::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t banti
banEntry.banReason = banReason;
if (bantimeoffset <= 0)
{
bantimeoffset = GetArg("-bantime", 60*60*24); // Default 24-hour ban
bantimeoffset = GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME); // Default 24-hour ban
sinceUnixEpoch = false;
}
banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime() )+bantimeoffset;
Expand Down Expand Up @@ -1452,7 +1452,7 @@ void ThreadDNSAddressSeed()
{
// goal: only query DNS seeds if address need is acute
if ((addrman.size() > 0) &&
(!GetBoolArg("-forcednsseed", false))) {
(!GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED))) {
MilliSleep(11 * 1000);

LOCK(cs_vNodes);
Expand Down Expand Up @@ -2325,8 +2325,8 @@ bool CAddrDB::Read(CAddrMan& addr, CDataStream& ssPeers)
return true;
}

unsigned int ReceiveFloodSize() { return 1000 * GetArg("-maxreceivebuffer", 5 * 1000); }
unsigned int SendBufferSize() { return 1000 * GetArg("-maxsendbuffer", 1 * 1000); }
unsigned int ReceiveFloodSize() { return 1000 * GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER); }
unsigned int SendBufferSize() { return 1000 * GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER); }

CNode::CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn, bool fInboundIn) :
ssSend(SER_NETWORK, INIT_PROTO_VERSION),
Expand Down
7 changes: 7 additions & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;

static const ServiceFlags REQUIRED_SERVICES = NODE_NETWORK;

static const bool DEFAULT_FORCEDNSSEED = false;
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;

// NOTE: When adjusting this, update rpcnet:setban's help ("24h")
static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban

unsigned int ReceiveFloodSize();
unsigned int SendBufferSize();

Expand Down
8 changes: 4 additions & 4 deletions src/pivx-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@

#define _(x) std::string(x) /* Keep the _() around in case gettext or such will be used later to translate non-UI */


static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;

std::string HelpMessageCli()
{
std::string strUsage;
strUsage += HelpMessageGroup(_("Options:"));
strUsage += HelpMessageOpt("-?", _("This help message"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "pivx.conf"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), PIVX_CONF_FILENAME));
strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory"));
strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be "
"solved instantly. This is intended for regression testing tools and app development."));
strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), "127.0.0.1"));
strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), DEFAULT_RPCCONNECT));
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), 51473, 51475));
strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start"));
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
Expand Down Expand Up @@ -142,7 +142,7 @@ static void http_request_done(struct evhttp_request *req, void *ctx)

UniValue CallRPC(const std::string& strMethod, const UniValue& params)
{
std::string host = GetArg("-rpcconnect", "127.0.0.1");
std::string host = GetArg("-rpcconnect", DEFAULT_RPCCONNECT);
int port = GetArg("-rpcport", BaseParams().RPCPort());

// Create event base
Expand Down
4 changes: 3 additions & 1 deletion src/policy/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include <boost/foreach.hpp>

bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;

/**
* Check transaction inputs to mitigate two
* potential denial-of-service attacks:
Expand Down Expand Up @@ -51,7 +53,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
if (m < 1 || m > n)
return false;
} else if (whichType == TX_NULL_DATA &&
(!GetBoolArg("-datacarrier", true) || scriptPubKey.size() > nMaxDatacarrierBytes))
(!GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER) || scriptPubKey.size() > nMaxDatacarrierBytes))
return false;

return whichType != TX_NONSTANDARD;
Expand Down
4 changes: 4 additions & 0 deletions src/policy/policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000;
static const unsigned int MAX_P2SH_SIGOPS = 15;
/** Default for -maxmempool, maximum megabytes of mempool memory usage */
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
/** Default for -permitbaremultisig */
static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
extern bool fIsBareMultisigStd;

/**
* Standard script verification flags that standard transactions will comply
* with. However scripts violating these flags may still be present in valid
Expand Down
2 changes: 1 addition & 1 deletion src/qt/intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ bool Intro::pickDataDirectory()
dataDir = settings.value("strDataDir", dataDir).toString();


if (!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || GetBoolArg("-choosedatadir", false)) {
if (!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR)) {
// If current default data directory does not exist, let the user choose one
Intro intro;
intro.setDataDirectory(dataDir);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ int main(int argc, char* argv[])
bool ret = true;
#ifdef ENABLE_WALLET
// Check if the wallet exists or need to be created
std::string strWalletFile = GetArg("-wallet", "wallet.dat");
std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
std::string strDataDir = GetDataDir().string();
// Wallet file must be a plain filename without a directory
fs::path wallet_file_path(strWalletFile);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/settings/settingsinformationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ SettingsInformationWidget::SettingsInformationWidget(PIVXGUI* _window,QWidget *p
#ifdef ENABLE_WALLET
// Wallet data -- remove it with if it's needed
ui->labelInfoBerkeley->setText(DbEnv::version(0, 0, 0));
ui->labelInfoDataDir->setText(QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + GetArg("-wallet", "wallet.dat")));
ui->labelInfoDataDir->setText(QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + GetArg("-wallet", DEFAULT_WALLET_DAT)));
#else
ui->labelInfoBerkeley->setText(tr("No information"));
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/topbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ void TopBar::updateHDState(const bool& upgraded, const QString& upgradeError)
}
} else {
inform(tr("Wallet upgraded successfully, but no backup created.") + "\n" +
tr("WARNING: remember to make a copy of your wallet.dat file!"));
tr("WARNING: remember to make a copy of your wallet file!"));
}
} else {
warn(tr("Upgrade Wallet Error"), upgradeError);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ RPCConsole::RPCConsole(QWidget* parent) : QDialog(parent, Qt::WindowSystemMenuHi
}

ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0));
ui->wallet_path->setText(QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + GetArg("-wallet", "wallet.dat")));
ui->wallet_path->setText(QString::fromStdString(GetDataDir().string() + QDir::separator().toLatin1() + GetArg("-wallet", DEFAULT_WALLET_DAT)));
#else

ui->label_berkeleyDBVersion->hide();
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ UniValue getstakingstatus(const JSONRPCRequest& request)
LOCK2(cs_main, &pwalletMain->cs_wallet);
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("staking_status", pwalletMain->pStakerStatus->IsActive()));
obj.push_back(Pair("staking_enabled", GetBoolArg("-staking", true)));
obj.push_back(Pair("staking_enabled", GetBoolArg("-staking", DEFAULT_STAKING)));
bool fColdStaking = GetBoolArg("-coldstaking", true);
obj.push_back(Pair("coldstaking_enabled", fColdStaking));
obj.push_back(Pair("haveconnections", !vNodes.empty()));
Expand Down
2 changes: 1 addition & 1 deletion src/script/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,4 @@ CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys)

bool IsValidDestination(const CTxDestination& dest) {
return dest.which() != 0;
}
}
2 changes: 2 additions & 0 deletions src/script/standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <stdint.h>

static const bool DEFAULT_ACCEPT_DATACARRIER = true;

class CKeyID;
class CScript;

Expand Down
10 changes: 7 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
#include <openssl/crypto.h>
#include <openssl/rand.h>

const char * const PIVX_CONF_FILENAME = "pivx.conf";
const char * const PIVX_PID_FILENAME = "pivx.pid";
const char * const PIVX_MASTERNODE_CONF_FILENAME = "masternode.conf";


// PIVX only features
// Masternode
Expand Down Expand Up @@ -448,13 +452,13 @@ void ClearDatadirCache()

fs::path GetConfigFile()
{
fs::path pathConfigFile(GetArg("-conf", "pivx.conf"));
fs::path pathConfigFile(GetArg("-conf", PIVX_CONF_FILENAME));
return AbsPathForConfigVal(pathConfigFile, false);
}

fs::path GetMasternodeConfigFile()
{
fs::path pathConfigFile(GetArg("-mnconf", "masternode.conf"));
fs::path pathConfigFile(GetArg("-mnconf", PIVX_MASTERNODE_CONF_FILENAME));
return AbsPathForConfigVal(pathConfigFile);
}

Expand Down Expand Up @@ -497,7 +501,7 @@ fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific)
#ifndef WIN32
fs::path GetPidFile()
{
fs::path pathPidFile(GetArg("-pid", "pivxd.pid"));
fs::path pathPidFile(GetArg("-pid", PIVX_PID_FILENAME));
return AbsPathForConfigVal(pathPidFile);
}

Expand Down
3 changes: 3 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include <boost/thread/exceptions.hpp>
#include <boost/thread/condition_variable.hpp> // for boost::thread_interrupted

extern const char * const PIVX_CONF_FILENAME;
extern const char * const PIVX_PID_FILENAME;
extern const char * const PIVX_MASTERNODE_CONF_FILENAME;
extern const char * const DEFAULT_DEBUGLOGFILE;

//PIVX only features
Expand Down
Loading