Bitcoin ABC  0.28.12
P2P Digital Currency
config.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017-2019 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <config.h>
6 
7 #include <chainparams.h>
8 #include <consensus/consensus.h> // DEFAULT_MAX_BLOCK_SIZE
9 
11  : useCashAddr(false), nMaxBlockSize(DEFAULT_MAX_BLOCK_SIZE) {}
12 
13 bool GlobalConfig::SetMaxBlockSize(uint64_t maxBlockSize) {
14  // Do not allow maxBlockSize to be set below historic 1MB limit
15  // It cannot be equal either because of the "must be big" UAHF rule.
16  if (maxBlockSize <= LEGACY_MAX_BLOCK_SIZE) {
17  return false;
18  }
19 
20  nMaxBlockSize = maxBlockSize;
21  return true;
22 }
23 
25  return nMaxBlockSize;
26 }
27 
29  return Params();
30 }
31 
33 
34 const Config &GetConfig() {
35  return gConfig;
36 }
37 
39  useCashAddr = c;
40 }
42  return useCashAddr;
43 }
44 
46  : chainParams(CreateChainParams(CBaseChainParams::REGTEST)) {}
47 
48 DummyConfig::DummyConfig(std::string net)
49  : chainParams(CreateChainParams(net)) {}
50 
51 DummyConfig::DummyConfig(std::unique_ptr<CChainParams> chainParamsIn)
52  : chainParams(std::move(chainParamsIn)) {}
53 
54 void DummyConfig::SetChainParams(std::string net) {
56 }
const CChainParams & Params()
Return the currently selected parameters.
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) of a given ins...
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:74
Definition: config.h:17
std::unique_ptr< CChainParams > chainParams
Definition: config.h:62
void SetChainParams(std::string net)
Definition: config.cpp:54
DummyConfig()
Definition: config.cpp:45
bool UseCashAddrEncoding() const override
Definition: config.cpp:41
bool useCashAddr
Definition: config.h:40
bool SetMaxBlockSize(uint64_t maxBlockSize) override
Definition: config.cpp:13
uint64_t nMaxBlockSize
The largest block size this node will accept.
Definition: config.h:43
const CChainParams & GetChainParams() const override
Definition: config.cpp:28
void SetCashAddrEncoding(bool) override
Definition: config.cpp:38
uint64_t GetMaxBlockSize() const override
Definition: config.cpp:24
GlobalConfig()
Definition: config.cpp:10
static GlobalConfig gConfig
Definition: config.cpp:32
const Config & GetConfig()
Definition: config.cpp:34
static const uint64_t LEGACY_MAX_BLOCK_SIZE
The maximum allowed size for a block, before the UAHF.
Definition: consensus.h:18
static const uint64_t DEFAULT_MAX_BLOCK_SIZE
Default setting for maximum allowed size for a block, in bytes.
Definition: consensus.h:20
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition: rcu.h:257