Bitcoin ABC  0.22.13
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 <amount.h>
9 #include <feerate.h>
10 
11 #include <boost/noncopyable.hpp>
12 
13 #include <cstdint>
14 #include <memory>
15 #include <string>
16 
17 class CChainParams;
18 
19 class Config : public boost::noncopyable {
20 public:
21  virtual bool SetMaxBlockSize(uint64_t maxBlockSize) = 0;
22  virtual uint64_t GetMaxBlockSize() const = 0;
23  virtual const CChainParams &GetChainParams() const = 0;
24  virtual void SetCashAddrEncoding(bool) = 0;
25  virtual bool UseCashAddrEncoding() const = 0;
26 
27  virtual void SetExcessUTXOCharge(Amount amt) = 0;
28  virtual Amount GetExcessUTXOCharge() const = 0;
29 };
30 
31 class GlobalConfig final : public Config {
32 public:
33  GlobalConfig();
34  bool SetMaxBlockSize(uint64_t maxBlockSize) override;
35  uint64_t GetMaxBlockSize() const override;
36  const CChainParams &GetChainParams() const override;
37  void SetCashAddrEncoding(bool) override;
38  bool UseCashAddrEncoding() const override;
39 
40  void SetExcessUTXOCharge(Amount) override;
41  Amount GetExcessUTXOCharge() const override;
42 
43 private:
46 
48  uint64_t nMaxBlockSize;
49 };
50 
51 // Dummy for subclassing in unittests
52 class DummyConfig : public Config {
53 public:
54  DummyConfig();
55  explicit DummyConfig(std::string net);
56  explicit DummyConfig(std::unique_ptr<CChainParams> chainParamsIn);
57  bool SetMaxBlockSize(uint64_t maxBlockSize) override { return false; }
58  uint64_t GetMaxBlockSize() const override { return 0; }
59 
60  void SetChainParams(std::string net);
61  const CChainParams &GetChainParams() const override { return *chainParams; }
62 
63  void SetCashAddrEncoding(bool) override {}
64  bool UseCashAddrEncoding() const override { return false; }
65 
66  void SetExcessUTXOCharge(Amount amt) override {}
67  Amount GetExcessUTXOCharge() const override { return Amount::zero(); }
68 
69 private:
70  std::unique_ptr<CChainParams> chainParams;
71 };
72 
73 // Temporary woraround.
74 const Config &GetConfig();
75 
76 #endif // BITCOIN_CONFIG_H
Amount excessUTXOCharge
Definition: config.h:45
virtual bool UseCashAddrEncoding() const =0
static constexpr Amount zero()
Definition: amount.h:35
void SetExcessUTXOCharge(Amount amt) override
Definition: config.h:66
uint64_t GetMaxBlockSize() const override
Definition: config.h:58
virtual Amount GetExcessUTXOCharge() const =0
Amount GetExcessUTXOCharge() const override
Definition: config.h:67
bool UseCashAddrEncoding() const override
Definition: config.h:64
std::unique_ptr< CChainParams > chainParams
Definition: config.h:70
Definition: amount.h:17
bool useCashAddr
Definition: config.h:44
bool SetMaxBlockSize(uint64_t maxBlockSize) override
Definition: config.h:57
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
Definition: chainparams.h:47
virtual const CChainParams & GetChainParams() const =0
virtual uint64_t GetMaxBlockSize() const =0
Definition: config.h:19
virtual void SetExcessUTXOCharge(Amount amt)=0
uint64_t nMaxBlockSize
The largest block size this node will accept.
Definition: config.h:48
virtual void SetCashAddrEncoding(bool)=0
const Config & GetConfig()
Definition: config.cpp:34
const CChainParams & GetChainParams() const override
Definition: config.h:61
void SetCashAddrEncoding(bool) override
Definition: config.h:63
virtual bool SetMaxBlockSize(uint64_t maxBlockSize)=0