Bitcoin ABC  0.29.4
P2P Digital Currency
config.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Amaury SÉCHET
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_CONFIG_H
6 #define BITCOIN_CONFIG_H
7 
8 #include <chainparams.h>
9 #include <consensus/amount.h>
10 #include <feerate.h>
11 
12 #include <cstdint>
13 #include <memory>
14 #include <optional>
15 #include <string>
16 
17 class CChainParams;
18 
19 class Config {
20 public:
21  virtual bool SetMaxBlockSize(uint64_t maxBlockSize) = 0;
22  virtual uint64_t GetMaxBlockSize() const = 0;
23  virtual void SetChainParams(const CChainParams chainParamsIn) = 0;
24  virtual const CChainParams &GetChainParams() const = 0;
25  virtual void SetCashAddrEncoding(bool) = 0;
26  virtual bool UseCashAddrEncoding() const = 0;
27 
28  Config() = default;
29  Config(const Config &) = delete;
30  Config &operator=(const Config &) = delete;
31 };
32 
33 class GlobalConfig final : public Config {
34 public:
35  GlobalConfig();
36  bool SetMaxBlockSize(uint64_t maxBlockSize) override;
37  uint64_t GetMaxBlockSize() const override;
38  void SetChainParams(const CChainParams chainParamsIn) override;
39  const CChainParams &GetChainParams() const override;
40  void SetCashAddrEncoding(bool) override;
41  bool UseCashAddrEncoding() const override;
42 
43 private:
45 
47  uint64_t nMaxBlockSize;
48 
49  std::optional<const CChainParams> chainParams;
50 };
51 
52 // Temporary woraround.
53 const Config &GetConfig();
54 
55 #endif // BITCOIN_CONFIG_H
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:80
Definition: config.h:19
virtual bool UseCashAddrEncoding() const =0
virtual uint64_t GetMaxBlockSize() const =0
Config()=default
Config & operator=(const Config &)=delete
Config(const Config &)=delete
virtual void SetChainParams(const CChainParams chainParamsIn)=0
virtual const CChainParams & GetChainParams() const =0
virtual bool SetMaxBlockSize(uint64_t maxBlockSize)=0
virtual void SetCashAddrEncoding(bool)=0
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
const Config & GetConfig()
Definition: config.cpp:40