Bitcoin ABC  0.29.9
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 <consensus/consensus.h> // DEFAULT_MAX_BLOCK_SIZE
8 
10  : useCashAddr(false), nMaxBlockSize(DEFAULT_MAX_BLOCK_SIZE) {}
11 
12 bool GlobalConfig::SetMaxBlockSize(uint64_t maxBlockSize) {
13  // Do not allow maxBlockSize to be set below historic 1MB limit
14  // It cannot be equal either because of the "must be big" UAHF rule.
15  if (maxBlockSize <= LEGACY_MAX_BLOCK_SIZE) {
16  return false;
17  }
18 
19  nMaxBlockSize = maxBlockSize;
20  return true;
21 }
22 
24  return nMaxBlockSize;
25 }
26 
27 void GlobalConfig::SetChainParams(const CChainParams chainParamsIn) {
28  chainParams.emplace(chainParamsIn);
29 }
30 
32  if (chainParams) {
33  return *chainParams;
34  }
35  return Params();
36 }
37 
39 
40 const Config &GetConfig() {
41  return gConfig;
42 }
43 
45  useCashAddr = c;
46 }
48  return useCashAddr;
49 }
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:19
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:80
Definition: config.h:19
bool UseCashAddrEncoding() const override
Definition: config.cpp:47
bool useCashAddr
Definition: config.h:44
bool SetMaxBlockSize(uint64_t maxBlockSize) override
Definition: config.cpp:12
void SetChainParams(const CChainParams chainParamsIn) override
Definition: config.cpp:27
uint64_t nMaxBlockSize
The largest block size this node will accept.
Definition: config.h:47
std::optional< const CChainParams > chainParams
Definition: config.h:49
const CChainParams & GetChainParams() const override
Definition: config.cpp:31
void SetCashAddrEncoding(bool) override
Definition: config.cpp:44
uint64_t GetMaxBlockSize() const override
Definition: config.cpp:23
GlobalConfig()
Definition: config.cpp:9
static GlobalConfig gConfig
Definition: config.cpp:38
const Config & GetConfig()
Definition: config.cpp:40
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