Skip to content

Commit

Permalink
Remove zPIV code from main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
presstab committed May 15, 2018
1 parent 9985266 commit 873ef19
Show file tree
Hide file tree
Showing 16 changed files with 434 additions and 375 deletions.
2 changes: 2 additions & 0 deletions src/Makefile.am
Expand Up @@ -194,6 +194,7 @@ BITCOIN_CORE_H = \
wallet.h \
wallet_ismine.h \
walletdb.h \
zpivchain.h \
zpivtracker.h \
zpivwallet.h \
zmq/zmqabstractnotifier.h \
Expand Down Expand Up @@ -243,6 +244,7 @@ libbitcoin_server_a_SOURCES = \
txdb.cpp \
txmempool.cpp \
validationinterface.cpp \
zpivchain.cpp \
$(BITCOIN_CORE_H)

if ENABLE_ZMQ
Expand Down
3 changes: 2 additions & 1 deletion src/accumulators.cpp
Expand Up @@ -10,6 +10,7 @@
#include "init.h"
#include "spork.h"
#include "accumulatorcheckpoints.h"
#include "zpivchain.h"

using namespace libzerocoin;

Expand Down Expand Up @@ -562,4 +563,4 @@ map<CoinDenomination, int> GetMintMaturityHeight()
mapRet.insert(make_pair(denom, mapDenomMaturity.at(denom).second));

return mapRet;
}
}
1 change: 1 addition & 0 deletions src/blocksignature.cpp
Expand Up @@ -4,6 +4,7 @@

#include "blocksignature.h"
#include "main.h"
#include "zpivchain.h"

bool SignBlockWithKey(CBlock& block, const CKey& key)
{
Expand Down
55 changes: 5 additions & 50 deletions src/init.cpp
Expand Up @@ -11,6 +11,7 @@

#include "init.h"

#include "accumulatorcheckpoints.h"
#include "accumulators.h"
#include "activemasternode.h"
#include "addrman.h"
Expand Down Expand Up @@ -39,7 +40,7 @@
#include "util.h"
#include "utilmoneystr.h"
#include "validationinterface.h"
#include "accumulatorcheckpoints.h"
#include "zpivchain.h"

#ifdef ENABLE_WALLET
#include "db.h"
Expand Down Expand Up @@ -1437,57 +1438,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Drop all information from the zerocoinDB and repopulate
if (GetBoolArg("-reindexzerocoin", false)) {
uiInterface.InitMessage(_("Reindexing zerocoin database..."));
if (!zerocoinDB->WipeCoins("spends") || !zerocoinDB->WipeCoins("mints")) {
strLoadError = _("Failed to wipe zerocoinDB");
std::string strError = ReindexZerocoinDB();
if (strError != "") {
strLoadError = strError;
break;
}

CBlockIndex* pindex = chainActive[Params().Zerocoin_StartHeight()];
while (pindex) {
if (pindex->nHeight % 1000 == 0)
LogPrintf("Reindexing zerocoin : block %d...\n", pindex->nHeight);

CBlock block;
if (!ReadBlockFromDisk(block, pindex)) {
strLoadError = _("Reindexing zerocoin failed");
break;
}

for (const CTransaction& tx : block.vtx) {
for (unsigned int i = 0; i < tx.vin.size(); i++) {
if (tx.IsCoinBase())
break;

if (tx.ContainsZerocoins()) {
uint256 txid = tx.GetHash();
//Record Serials
if (tx.IsZerocoinSpend()) {
for (auto& in : tx.vin) {
if (!in.scriptSig.IsZerocoinSpend())
continue;

libzerocoin::CoinSpend spend = TxInToZerocoinSpend(in);
zerocoinDB->WriteCoinSpend(spend.getCoinSerialNumber(), txid);
}
}

//Record mints
if (tx.IsZerocoinMint()) {
for (auto& out : tx.vout) {
if (!out.IsZerocoinMint())
continue;

CValidationState state;
libzerocoin::PublicCoin coin(Params().Zerocoin_Params(pindex->nHeight < Params().Zerocoin_Block_V2_Start()));
TxOutToPublicCoin(out, coin, state);
zerocoinDB->WriteCoinMint(coin, txid);
}
}
}
}
}
pindex = chainActive.Next(pindex);
}
}

// Recalculate money supply for blocks that are impacted by accounting issue after zerocoin activation
Expand Down
1 change: 1 addition & 0 deletions src/kernel.cpp
Expand Up @@ -12,6 +12,7 @@
#include "timedata.h"
#include "util.h"
#include "stakeinput.h"
#include "zpivchain.h"

using namespace std;

Expand Down

0 comments on commit 873ef19

Please sign in to comment.