Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core14 changes #846

Merged
merged 6 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/hdmint/tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ bool CHDMintTracker::UnArchive(const uint256& hashPubcoin, bool isDeterministic)
CHDMint dMint;
if (!walletdb.UnarchiveHDMint(hashPubcoin, dMint))
return error("%s: failed to unarchive deterministic mint", __func__);
Add(dMint, false);
Add(walletdb, dMint, false);
} else {
CSigmaEntry sigma;
if (!walletdb.UnarchiveSigmaMint(hashPubcoin, sigma))
return error("%s: failed to unarchivesigma mint", __func__);
Add(sigma, false);
Add(walletdb, sigma, false);
}

LogPrintf("%s: unarchived %s\n", __func__, hashPubcoin.GetHex());
Expand Down Expand Up @@ -283,7 +283,7 @@ bool CHDMintTracker::UpdateState(const CMintMeta& meta)
* @param isArchived set to true if this mint is archived, used to set meta object correctly
* @return success
*/
void CHDMintTracker::Add(const CHDMint& dMint, bool isNew, bool isArchived)
void CHDMintTracker::Add(CWalletDB& walletdb, const CHDMint& dMint, bool isNew, bool isArchived)
{
CMintMeta meta;
meta.SetPubCoinValue(dMint.GetPubcoinValue());
Expand All @@ -305,10 +305,10 @@ void CHDMintTracker::Add(const CHDMint& dMint, bool isNew, bool isArchived)
CT_UPDATED);

if (isNew)
CWalletDB(strWalletFile).WriteHDMint(dMint);
walletdb.WriteHDMint(dMint);
}

void CHDMintTracker::Add(const CSigmaEntry& sigma, bool isNew, bool isArchived)
void CHDMintTracker::Add(CWalletDB& walletdb, const CSigmaEntry& sigma, bool isNew, bool isArchived)
{
CMintMeta meta;
meta.SetPubCoinValue(sigma.value);
Expand All @@ -324,7 +324,7 @@ void CHDMintTracker::Add(const CSigmaEntry& sigma, bool isNew, bool isArchived)
mapSerialHashes[meta.hashSerial] = meta;

if (isNew)
CWalletDB(strWalletFile).WriteSigmaEntry(sigma);
walletdb.WriteSigmaEntry(sigma);
}

/**
Expand Down Expand Up @@ -516,7 +516,7 @@ bool CHDMintTracker::UpdateMetaStatus(const std::set<uint256>& setMempool, CMint
*/
void CHDMintTracker::UpdateFromBlock(const std::list<std::pair<uint256, MintPoolEntry>>& mintPoolEntries, const std::vector<CMintMeta>& updatedMeta){
if (mintPoolEntries.size() > 0) {
zwalletMain->SyncWithChain(false, mintPoolEntries);
pwalletMain->zwallet->SyncWithChain(false, mintPoolEntries);
}

//overwrite any updates
Expand Down Expand Up @@ -720,13 +720,13 @@ std::vector<CMintMeta> CHDMintTracker::ListMints(bool fUnusedOnly, bool fMatureO
std::list<CSigmaEntry> listMintsDB;
walletdb.ListSigmaPubCoin(listMintsDB);
for (auto& mint : listMintsDB){
Add(mint);
Add(walletdb, mint);
}
LogPrint("zero", "%s: added %d sigmamints from DB\n", __func__, listMintsDB.size());

std::list<CHDMint> listDeterministicDB = walletdb.ListHDMints();
for (auto& dMint : listDeterministicDB) {
Add(dMint, false, false);
Add(walletdb, dMint, false, false);
}
LogPrint("zero", "%s: added %d hdmint from DB\n", __func__, listDeterministicDB.size());
}
Expand Down
5 changes: 3 additions & 2 deletions src/hdmint/tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "primitives/zerocoin.h"
#include "hdmint/mintpool.h"
#include "wallet/walletdb.h"
#include <list>

class CHDMint;
Expand All @@ -25,8 +26,8 @@ class CHDMintTracker
public:
CHDMintTracker(std::string strWalletFile);
~CHDMintTracker();
void Add(const CHDMint& dMint, bool isNew = false, bool isArchived = false);
void Add(const CSigmaEntry& sigma, bool isNew = false, bool isArchived = false);
void Add(CWalletDB& walletdb, const CHDMint& dMint, bool isNew = false, bool isArchived = false);
void Add(CWalletDB& walletdb, const CSigmaEntry& sigma, bool isNew = false, bool isArchived = false);
bool Archive(CMintMeta& meta);
bool HasPubcoinHash(const uint256& hashPubcoin) const;
bool HasSerialHash(const uint256& hashSerial) const;
Expand Down
Loading