mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-01-31 18:40:58 +00:00
bugfix: change asserts into handled failures for cmpctblk
Replaces assert() calls with if() statements returning functional failure that can be handled for situations that can be triggered from outside of compiled code - i.e. peers. Backported from: 42bd4c74 Original Author: dergoegge <n.goeggi@gmail.com>
This commit is contained in:
parent
ad75b56535
commit
149be06daf
@ -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());
|
||||
|
||||
@ -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());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user