PIVX Core
5.6.99
P2P Digital Currency
src
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
;
17
CAmount
nSupply
;
18
// height of the chain when the supply was last updated
19
int64_t
nHeight
;
20
21
public
:
22
CMoneySupply
():
nSupply
(0),
nHeight
(0) {}
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
amount.h
CAmount
int64_t CAmount
Amount in PIV (Can be negative)
Definition:
amount.h:13
AnnotatedMixin< std::recursive_mutex >
CMoneySupply
Definition:
moneysupply.h:14
CMoneySupply::nSupply
CAmount nSupply
Definition:
moneysupply.h:17
CMoneySupply::nHeight
int64_t nHeight
Definition:
moneysupply.h:19
CMoneySupply::Update
void Update(const CAmount &_nSupply, int _nHeight)
Definition:
moneysupply.h:24
CMoneySupply::cs
RecursiveMutex cs
Definition:
moneysupply.h:16
CMoneySupply::Get
CAmount Get() const
Definition:
moneysupply.h:31
CMoneySupply::CMoneySupply
CMoneySupply()
Definition:
moneysupply.h:22
CMoneySupply::GetCacheHeight
int64_t GetCacheHeight() const
Definition:
moneysupply.h:32
LOCK
@ LOCK
Definition:
lockunlock.h:16
sync.h
Generated on Wed Apr 2 2025 00:40:30 for PIVX Core by
1.9.1