PIVX Core  5.6.99
P2P Digital Currency
moneysupply.h
Go to the documentation of this file.
1 // Copyright (c) 2020 The PIVX Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or https://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef PIVX_MONEYSUPPLY_H
6 #define PIVX_MONEYSUPPLY_H
7 
8 #include "amount.h"
9 #include "sync.h"
10 
11 /*
12  * Class used to cache the sum of utxo's values
13  */
14 class CMoneySupply {
15 private:
16  mutable RecursiveMutex cs;
18  // height of the chain when the supply was last updated
19  int64_t nHeight;
20 
21 public:
23 
24  void Update(const CAmount& _nSupply, int _nHeight)
25  {
26  LOCK(cs);
27  nSupply = _nSupply;
28  nHeight = _nHeight;
29  }
30 
31  CAmount Get() const { LOCK(cs); return nSupply; }
32  int64_t GetCacheHeight() const { LOCK(cs); return nHeight; }
33 };
34 
35 #endif // PIVX_MONEYSUPPLY_H
int64_t CAmount
Amount in PIV (Can be negative)
Definition: amount.h:13
CAmount nSupply
Definition: moneysupply.h:17
int64_t nHeight
Definition: moneysupply.h:19
void Update(const CAmount &_nSupply, int _nHeight)
Definition: moneysupply.h:24
RecursiveMutex cs
Definition: moneysupply.h:16
CAmount Get() const
Definition: moneysupply.h:31
int64_t GetCacheHeight() const
Definition: moneysupply.h:32
@ LOCK
Definition: lockunlock.h:16