Skip to content

Commit 6c91446

Browse files
committed
Expose check_pow for compact blocks, helper to get available Tx list
1 parent d1eaa44 commit 6c91446

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/blockencodings.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const uint256& txhash) const {
4343
return SipHashUint256(shorttxidk0, shorttxidk1, txhash) & 0xffffffffffffL;
4444
}
4545

46-
46+
std::vector<CTransactionRef> PartiallyDownloadedBlock::GetAvailableTx() {
47+
std::vector<CTransactionRef> found_tx;
48+
for (unsigned int i = 0; i < txn_available.size(); i++) {
49+
if (txn_available[i]) found_tx.push_back(txn_available[i]);
50+
}
51+
return found_tx;
52+
}
4753

4854
ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector<std::pair<uint256, CTransactionRef>>& extra_txn) {
4955
if (cmpctblock.header.IsNull() || (cmpctblock.shorttxids.empty() && cmpctblock.prefilledtxn.empty()))
@@ -173,7 +179,7 @@ bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
173179
return txn_available[index] != nullptr;
174180
}
175181

176-
ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) {
182+
ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing, bool check_pow) {
177183
assert(!header.IsNull());
178184
uint256 hash = header.GetHash();
179185
block = header;
@@ -197,7 +203,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
197203
return READ_STATUS_INVALID;
198204

199205
CValidationState state;
200-
if (!CheckBlock(block, state, Params().GetConsensus())) {
206+
if (!CheckBlock(block, state, Params().GetConsensus(), check_pow)) {
201207
// TODO: We really want to just check merkle tree manually here,
202208
// but that is expensive, and CheckBlock caches a block's
203209
// "checked-status" (in the CBlock?). CBlock should be able to

src/blockencodings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,11 @@ class PartiallyDownloadedBlock {
200200
CBlockHeader header;
201201
explicit PartiallyDownloadedBlock(CTxMemPool* poolIn) : pool(poolIn) {}
202202

203+
std::vector<CTransactionRef> GetAvailableTx();
203204
// extra_txn is a list of extra transactions to look at, in <witness hash, reference> form
204205
ReadStatus InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector<std::pair<uint256, CTransactionRef>>& extra_txn);
205206
bool IsTxAvailable(size_t index) const;
206-
ReadStatus FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing);
207+
ReadStatus FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing, bool check_pow = true);
207208
};
208209

209210
#endif // BITCOIN_BLOCKENCODINGS_H

0 commit comments

Comments
 (0)