Changeset View
Changeset View
Standalone View
Standalone View
src/config.cpp
// Copyright (c) 2017 The Bitcoin developers | // Copyright (c) 2017 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <config.h> | #include <config.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <consensus/consensus.h> // DEFAULT_MAX_BLOCK_SIZE | #include <consensus/consensus.h> // DEFAULT_MAX_BLOCK_SIZE | ||||
#include <globals.h> | #include <globals.h> | ||||
#include <policy/policy.h> // DEFAULT_BLOCK_PRIORITY_PERCENTAGE | |||||
GlobalConfig::GlobalConfig() | GlobalConfig::GlobalConfig() | ||||
: useCashAddr(false), nMaxBlockSize(DEFAULT_MAX_BLOCK_SIZE), | : useCashAddr(false), nMaxBlockSize(DEFAULT_MAX_BLOCK_SIZE) {} | ||||
nBlockPriorityPercentage(DEFAULT_BLOCK_PRIORITY_PERCENTAGE) {} | |||||
bool GlobalConfig::SetMaxBlockSize(uint64_t maxBlockSize) { | bool GlobalConfig::SetMaxBlockSize(uint64_t maxBlockSize) { | ||||
// Do not allow maxBlockSize to be set below historic 1MB limit | // Do not allow maxBlockSize to be set below historic 1MB limit | ||||
// It cannot be equal either because of the "must be big" UAHF rule. | // It cannot be equal either because of the "must be big" UAHF rule. | ||||
if (maxBlockSize <= LEGACY_MAX_BLOCK_SIZE) { | if (maxBlockSize <= LEGACY_MAX_BLOCK_SIZE) { | ||||
return false; | return false; | ||||
} | } | ||||
nMaxBlockSize = maxBlockSize; | nMaxBlockSize = maxBlockSize; | ||||
return true; | return true; | ||||
} | } | ||||
uint64_t GlobalConfig::GetMaxBlockSize() const { | uint64_t GlobalConfig::GetMaxBlockSize() const { | ||||
return nMaxBlockSize; | return nMaxBlockSize; | ||||
} | } | ||||
bool GlobalConfig::SetBlockPriorityPercentage(int64_t blockPriorityPercentage) { | |||||
// blockPriorityPercentage has to belong to [0..100] | |||||
if ((blockPriorityPercentage < 0) || (blockPriorityPercentage > 100)) { | |||||
return false; | |||||
} | |||||
nBlockPriorityPercentage = blockPriorityPercentage; | |||||
return true; | |||||
} | |||||
uint8_t GlobalConfig::GetBlockPriorityPercentage() const { | |||||
return nBlockPriorityPercentage; | |||||
} | |||||
const CChainParams &GlobalConfig::GetChainParams() const { | const CChainParams &GlobalConfig::GetChainParams() const { | ||||
return Params(); | return Params(); | ||||
} | } | ||||
static GlobalConfig gConfig; | static GlobalConfig gConfig; | ||||
const Config &GetConfig() { | const Config &GetConfig() { | ||||
return gConfig; | return gConfig; | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |