This repository has been archived by the owner on Jun 20, 2022. It is now read-only.
forked from PIVX-Project/PIVX
/
zpivtracker.h
52 lines (47 loc) · 2.14 KB
/
zpivtracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2018 The PIVX developers
// Copyright (c) 2018-2019 The DOMO developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef DOMO_ZDOMOTRACKER_H
#define DOMO_ZDOMOTRACKER_H
#include "primitives/zerocoin.h"
#include <list>
class CDeterministicMint;
class CzDOMOTracker
{
private:
bool fInitialized;
std::string strWalletFile;
std::map<uint256, CMintMeta> mapSerialHashes;
std::map<uint256, uint256> mapPendingSpends; //serialhash, txid of spend
bool UpdateStatusInternal(const std::set<uint256>& setMempool, CMintMeta& mint);
public:
CzDOMOTracker(std::string strWalletFile);
~CzDOMOTracker();
void Add(const CDeterministicMint& dMint, bool isNew = false, bool isArchived = false);
void Add(const CZerocoinMint& mint, bool isNew = false, bool isArchived = false);
bool Archive(CMintMeta& meta);
bool HasPubcoin(const CBigNum& bnValue) const;
bool HasPubcoinHash(const uint256& hashPubcoin) const;
bool HasSerial(const CBigNum& bnSerial) const;
bool HasSerialHash(const uint256& hashSerial) const;
bool HasMintTx(const uint256& txid);
bool IsEmpty() const { return mapSerialHashes.empty(); }
void Init();
CMintMeta Get(const uint256& hashSerial);
CMintMeta GetMetaFromPubcoin(const uint256& hashPubcoin);
bool GetMetaFromStakeHash(const uint256& hashStake, CMintMeta& meta) const;
CAmount GetBalance(bool fConfirmedOnly, bool fUnconfirmedOnly) const;
std::vector<uint256> GetSerialHashes();
std::vector<CMintMeta> GetMints(bool fConfirmedOnly) const;
CAmount GetUnconfirmedBalance() const;
std::set<CMintMeta> ListMints(bool fUnusedOnly, bool fMatureOnly, bool fUpdateStatus);
void RemovePending(const uint256& txid);
void SetPubcoinUsed(const uint256& hashPubcoin, const uint256& txid);
void SetPubcoinNotUsed(const uint256& hashPubcoin);
bool UnArchive(const uint256& hashPubcoin, bool isDeterministic);
bool UpdateZerocoinMint(const CZerocoinMint& mint);
bool UpdateState(const CMintMeta& meta);
void Clear();
};
#endif //DOMO_ZDOMOTRACKER_H