Skip to content

Commit 873ef19

Browse files
committed
Remove zPIV code from main.cpp
1 parent 9985266 commit 873ef19

16 files changed

+434
-375
lines changed

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ BITCOIN_CORE_H = \
194194
wallet.h \
195195
wallet_ismine.h \
196196
walletdb.h \
197+
zpivchain.h \
197198
zpivtracker.h \
198199
zpivwallet.h \
199200
zmq/zmqabstractnotifier.h \
@@ -243,6 +244,7 @@ libbitcoin_server_a_SOURCES = \
243244
txdb.cpp \
244245
txmempool.cpp \
245246
validationinterface.cpp \
247+
zpivchain.cpp \
246248
$(BITCOIN_CORE_H)
247249

248250
if ENABLE_ZMQ

src/accumulators.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "init.h"
1111
#include "spork.h"
1212
#include "accumulatorcheckpoints.h"
13+
#include "zpivchain.h"
1314

1415
using namespace libzerocoin;
1516

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

564565
return mapRet;
565-
}
566+
}

src/blocksignature.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "blocksignature.h"
66
#include "main.h"
7+
#include "zpivchain.h"
78

89
bool SignBlockWithKey(CBlock& block, const CKey& key)
910
{

src/init.cpp

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "init.h"
1313

14+
#include "accumulatorcheckpoints.h"
1415
#include "accumulators.h"
1516
#include "activemasternode.h"
1617
#include "addrman.h"
@@ -39,7 +40,7 @@
3940
#include "util.h"
4041
#include "utilmoneystr.h"
4142
#include "validationinterface.h"
42-
#include "accumulatorcheckpoints.h"
43+
#include "zpivchain.h"
4344

4445
#ifdef ENABLE_WALLET
4546
#include "db.h"
@@ -1437,57 +1438,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
14371438
// Drop all information from the zerocoinDB and repopulate
14381439
if (GetBoolArg("-reindexzerocoin", false)) {
14391440
uiInterface.InitMessage(_("Reindexing zerocoin database..."));
1440-
if (!zerocoinDB->WipeCoins("spends") || !zerocoinDB->WipeCoins("mints")) {
1441-
strLoadError = _("Failed to wipe zerocoinDB");
1441+
std::string strError = ReindexZerocoinDB();
1442+
if (strError != "") {
1443+
strLoadError = strError;
14421444
break;
14431445
}
1444-
1445-
CBlockIndex* pindex = chainActive[Params().Zerocoin_StartHeight()];
1446-
while (pindex) {
1447-
if (pindex->nHeight % 1000 == 0)
1448-
LogPrintf("Reindexing zerocoin : block %d...\n", pindex->nHeight);
1449-
1450-
CBlock block;
1451-
if (!ReadBlockFromDisk(block, pindex)) {
1452-
strLoadError = _("Reindexing zerocoin failed");
1453-
break;
1454-
}
1455-
1456-
for (const CTransaction& tx : block.vtx) {
1457-
for (unsigned int i = 0; i < tx.vin.size(); i++) {
1458-
if (tx.IsCoinBase())
1459-
break;
1460-
1461-
if (tx.ContainsZerocoins()) {
1462-
uint256 txid = tx.GetHash();
1463-
//Record Serials
1464-
if (tx.IsZerocoinSpend()) {
1465-
for (auto& in : tx.vin) {
1466-
if (!in.scriptSig.IsZerocoinSpend())
1467-
continue;
1468-
1469-
libzerocoin::CoinSpend spend = TxInToZerocoinSpend(in);
1470-
zerocoinDB->WriteCoinSpend(spend.getCoinSerialNumber(), txid);
1471-
}
1472-
}
1473-
1474-
//Record mints
1475-
if (tx.IsZerocoinMint()) {
1476-
for (auto& out : tx.vout) {
1477-
if (!out.IsZerocoinMint())
1478-
continue;
1479-
1480-
CValidationState state;
1481-
libzerocoin::PublicCoin coin(Params().Zerocoin_Params(pindex->nHeight < Params().Zerocoin_Block_V2_Start()));
1482-
TxOutToPublicCoin(out, coin, state);
1483-
zerocoinDB->WriteCoinMint(coin, txid);
1484-
}
1485-
}
1486-
}
1487-
}
1488-
}
1489-
pindex = chainActive.Next(pindex);
1490-
}
14911446
}
14921447

14931448
// Recalculate money supply for blocks that are impacted by accounting issue after zerocoin activation

src/kernel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "timedata.h"
1313
#include "util.h"
1414
#include "stakeinput.h"
15+
#include "zpivchain.h"
1516

1617
using namespace std;
1718

0 commit comments

Comments
 (0)