Skip to content

Commit

Permalink
Merge pull request dogecoin#3661 from patricklodder/bug/fix_cmpctblk_…
Browse files Browse the repository at this point in the history
…encoding_asserts

bugfix: change asserts into handled failures for cmpctblk
  • Loading branch information
chromatic authored Oct 12, 2024
2 parents ad75b56 + 149be06 commit f2542d2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/blockencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_BASE_SIZE / MIN_TRANSACTION_BASE_SIZE)
return READ_STATUS_INVALID;

assert(header.IsNull() && txn_available.empty());
if (!header.IsNull() || !txn_available.empty()) {
return READ_STATUS_FAILED;
}

header = cmpctblock.header;
txn_available.resize(cmpctblock.BlockTxCount());

Expand Down Expand Up @@ -170,13 +173,19 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
}

bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
assert(!header.IsNull());
if (header.IsNull()) {
return false;
}

assert(index < txn_available.size());
return txn_available[index] ? true : false;
}

ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) {
assert(!header.IsNull());
if (header.IsNull()) {
return READ_STATUS_INVALID;
}

uint256 hash = header.GetHash();
block = header;
block.vtx.resize(txn_available.size());
Expand Down

0 comments on commit f2542d2

Please sign in to comment.