Skip to content

Commit 5e81e5d

Browse files
committed
Move-only: DataBaseAccChecksum to zerocoin validation legacy.
1 parent 81d2654 commit 5e81e5d

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

src/legacy/validation_zerocoin_legacy.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,30 @@ bool DisconnectZerocoinTx(const CTransaction& tx, CAmount& nValueIn, CZerocoinDB
6767
}
6868
}
6969
return true;
70-
}
70+
}
71+
72+
// Legacy Zerocoin DB: used for performance during IBD
73+
// (between Zerocoin_Block_V2_Start and Zerocoin_Block_Last_Checkpoint)
74+
void DataBaseAccChecksum(CBlockIndex* pindex, bool fWrite)
75+
{
76+
const Consensus::Params& consensus = Params().GetConsensus();
77+
if (!pindex ||
78+
!consensus.NetworkUpgradeActive(pindex->nHeight, Consensus::UPGRADE_ZC_V2) ||
79+
pindex->nHeight > consensus.height_last_ZC_AccumCheckpoint ||
80+
pindex->nAccumulatorCheckpoint == pindex->pprev->nAccumulatorCheckpoint)
81+
return;
82+
83+
uint256 accCurr = pindex->nAccumulatorCheckpoint;
84+
uint256 accPrev = pindex->pprev->nAccumulatorCheckpoint;
85+
// add/remove changed checksums to/from DB
86+
for (int i = (int)libzerocoin::zerocoinDenomList.size()-1; i >= 0; i--) {
87+
const uint32_t& nChecksum = accCurr.Get32();
88+
if (nChecksum != accPrev.Get32()) {
89+
fWrite ?
90+
zerocoinDB->WriteAccChecksum(nChecksum, libzerocoin::zerocoinDenomList[i], pindex->nHeight) :
91+
zerocoinDB->EraseAccChecksum(nChecksum, libzerocoin::zerocoinDenomList[i]);
92+
}
93+
accCurr >>= 32;
94+
accPrev >>= 32;
95+
}
96+
}

src/legacy/validation_zerocoin_legacy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
#include "txdb.h" // for the zerocoinDB implementation.
1111

1212
bool DisconnectZerocoinTx(const CTransaction& tx, CAmount& nValueIn, CZerocoinDB* zerocoinDB);
13+
void DataBaseAccChecksum(CBlockIndex* pindex, bool fWrite);
1314

1415
#endif //VALIDATION_ZEROCOIN_LEGACY_H

src/main.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,32 +1936,6 @@ static bool AbortNode(CValidationState& state, const std::string& strMessage, co
19361936
return state.Error(strMessage);
19371937
}
19381938

1939-
// Legacy Zerocoin DB: used for performance during IBD
1940-
// (between Zerocoin_Block_V2_Start and Zerocoin_Block_Last_Checkpoint)
1941-
void DataBaseAccChecksum(CBlockIndex* pindex, bool fWrite)
1942-
{
1943-
const Consensus::Params& consensus = Params().GetConsensus();
1944-
if (!pindex ||
1945-
!consensus.NetworkUpgradeActive(pindex->nHeight, Consensus::UPGRADE_ZC_V2) ||
1946-
pindex->nHeight > consensus.height_last_ZC_AccumCheckpoint ||
1947-
pindex->nAccumulatorCheckpoint == pindex->pprev->nAccumulatorCheckpoint)
1948-
return;
1949-
1950-
uint256 accCurr = pindex->nAccumulatorCheckpoint;
1951-
uint256 accPrev = pindex->pprev->nAccumulatorCheckpoint;
1952-
// add/remove changed checksums to/from DB
1953-
for (int i = (int)libzerocoin::zerocoinDenomList.size()-1; i >= 0; i--) {
1954-
const uint32_t& nChecksum = accCurr.Get32();
1955-
if (nChecksum != accPrev.Get32()) {
1956-
fWrite ?
1957-
zerocoinDB->WriteAccChecksum(nChecksum, libzerocoin::zerocoinDenomList[i], pindex->nHeight) :
1958-
zerocoinDB->EraseAccChecksum(nChecksum, libzerocoin::zerocoinDenomList[i]);
1959-
}
1960-
accCurr >>= 32;
1961-
accPrev >>= 32;
1962-
}
1963-
}
1964-
19651939
bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool* pfClean)
19661940
{
19671941
AssertLockHeld(cs_main);

0 commit comments

Comments
 (0)