fixed the txindex data

This commit is contained in:
Brannon King 2019-12-10 22:43:07 -07:00
parent 737ee8c641
commit bb240e290b
2 changed files with 7 additions and 4 deletions

View file

@ -372,6 +372,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
}
bool CBlockTreeDB::WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos>> &list) {
if (list.empty()) return true;
db << "begin";
auto query = db << "INSERT OR REPLACE INTO tx_to_block VALUES(?,?,?,?)";
for (auto& kvp: list) {

View file

@ -2088,10 +2088,12 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
if (fJustCheck)
return true;
if (pindex->pprev != nullptr &&
!WriteUndoDataForBlock(blockundo, state, pindex, chainparams) &&
!pblocktree->WriteTxIndex(vPos))
return false;
if (pindex->pprev != nullptr) {
if (!WriteUndoDataForBlock(blockundo, state, pindex, chainparams))
return error("Unable to write to the Undo data block");
if (!pblocktree->WriteTxIndex(vPos))
return error("Unable to write to the TX Index");
}
if (!pindex->IsValid(BLOCK_VALID_SCRIPTS)) {
pindex->RaiseValidity(BLOCK_VALID_SCRIPTS);