mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
[block encodings] Avoid fuzz blocking asserts in PartiallyDownloadedBlock
This commit is contained in:
parent
1429f83770
commit
42bd4c7468
1 changed files with 10 additions and 5 deletions
|
@ -52,7 +52,8 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
|
||||||
if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_WEIGHT / MIN_SERIALIZABLE_TRANSACTION_WEIGHT)
|
if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_WEIGHT / MIN_SERIALIZABLE_TRANSACTION_WEIGHT)
|
||||||
return READ_STATUS_INVALID;
|
return READ_STATUS_INVALID;
|
||||||
|
|
||||||
assert(header.IsNull() && txn_available.empty());
|
if (!header.IsNull() || !txn_available.empty()) return READ_STATUS_INVALID;
|
||||||
|
|
||||||
header = cmpctblock.header;
|
header = cmpctblock.header;
|
||||||
txn_available.resize(cmpctblock.BlockTxCount());
|
txn_available.resize(cmpctblock.BlockTxCount());
|
||||||
|
|
||||||
|
@ -167,14 +168,18 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
|
||||||
return READ_STATUS_OK;
|
return READ_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
|
bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const
|
||||||
assert(!header.IsNull());
|
{
|
||||||
|
if (header.IsNull()) return false;
|
||||||
|
|
||||||
assert(index < txn_available.size());
|
assert(index < txn_available.size());
|
||||||
return txn_available[index] != nullptr;
|
return txn_available[index] != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) {
|
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();
|
uint256 hash = header.GetHash();
|
||||||
block = header;
|
block = header;
|
||||||
block.vtx.resize(txn_available.size());
|
block.vtx.resize(txn_available.size());
|
||||||
|
|
Loading…
Add table
Reference in a new issue