fix: DisconnectBlock/RollforwardBlock/ReplayBlocks log fixes

This commit is contained in:
UdjinM6 2023-07-05 21:29:34 +03:00
parent 8a04faea39
commit 075d02b691

View File

@ -1760,6 +1760,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
std::vector<std::pair<CSpentIndexKey, CSpentIndexValue> > spentIndex; std::vector<std::pair<CSpentIndexKey, CSpentIndexValue> > spentIndex;
if (!UndoSpecialTxsInBlock(block, pindex, *m_quorum_block_processor)) { if (!UndoSpecialTxsInBlock(block, pindex, *m_quorum_block_processor)) {
error("DisconnectBlock(): UndoSpecialTxsInBlock failed");
return DISCONNECT_FAILED; return DISCONNECT_FAILED;
} }
@ -4901,7 +4902,7 @@ bool CChainState::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& i
// TODO: merge with ConnectBlock // TODO: merge with ConnectBlock
CBlock block; CBlock block;
if (!ReadBlockFromDisk(block, pindex, m_params.GetConsensus())) { if (!ReadBlockFromDisk(block, pindex, m_params.GetConsensus())) {
return error("ReplayBlock(): ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); return error("RollforwardBlock(): ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
} }
// MUST process special txes before updating UTXO to ensure consistency between mempool and block processing // MUST process special txes before updating UTXO to ensure consistency between mempool and block processing
@ -4966,12 +4967,12 @@ bool CChainState::ReplayBlocks()
if (pindexOld->nHeight > 0) { // Never disconnect the genesis block. if (pindexOld->nHeight > 0) { // Never disconnect the genesis block.
CBlock block; CBlock block;
if (!ReadBlockFromDisk(block, pindexOld, m_params.GetConsensus())) { if (!ReadBlockFromDisk(block, pindexOld, m_params.GetConsensus())) {
return error("RollbackBlock(): ReadBlockFromDisk() failed at %d, hash=%s", pindexOld->nHeight, pindexOld->GetBlockHash().ToString()); return error("ReplayBlocks(): ReadBlockFromDisk() failed at %d, hash=%s", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
} }
LogPrintf("Rolling back %s (%i)\n", pindexOld->GetBlockHash().ToString(), pindexOld->nHeight); LogPrintf("Rolling back %s (%i)\n", pindexOld->GetBlockHash().ToString(), pindexOld->nHeight);
DisconnectResult res = DisconnectBlock(block, pindexOld, cache); DisconnectResult res = DisconnectBlock(block, pindexOld, cache);
if (res == DISCONNECT_FAILED) { if (res == DISCONNECT_FAILED) {
return error("RollbackBlock(): DisconnectBlock failed at %d, hash=%s", pindexOld->nHeight, pindexOld->GetBlockHash().ToString()); return error("ReplayBlocks(): DisconnectBlock failed at %d, hash=%s", pindexOld->nHeight, pindexOld->GetBlockHash().ToString());
} }
// If DISCONNECT_UNCLEAN is returned, it means a non-existing UTXO was deleted, or an existing UTXO was // If DISCONNECT_UNCLEAN is returned, it means a non-existing UTXO was deleted, or an existing UTXO was
// overwritten. It corresponds to cases where the block-to-be-disconnect never had all its operations // overwritten. It corresponds to cases where the block-to-be-disconnect never had all its operations