mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Expose check_pow for compact blocks, helper to get available Tx list
This commit is contained in:
parent
d1eaa44ba1
commit
6c91446982
2 changed files with 11 additions and 4 deletions
|
|
@ -43,7 +43,13 @@ uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const uint256& txhash) const {
|
|||
return SipHashUint256(shorttxidk0, shorttxidk1, txhash) & 0xffffffffffffL;
|
||||
}
|
||||
|
||||
|
||||
std::vector<CTransactionRef> PartiallyDownloadedBlock::GetAvailableTx() {
|
||||
std::vector<CTransactionRef> found_tx;
|
||||
for (unsigned int i = 0; i < txn_available.size(); i++) {
|
||||
if (txn_available[i]) found_tx.push_back(txn_available[i]);
|
||||
}
|
||||
return found_tx;
|
||||
}
|
||||
|
||||
ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector<std::pair<uint256, CTransactionRef>>& extra_txn) {
|
||||
if (cmpctblock.header.IsNull() || (cmpctblock.shorttxids.empty() && cmpctblock.prefilledtxn.empty()))
|
||||
|
|
@ -173,7 +179,7 @@ bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
|
|||
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, bool check_pow) {
|
||||
assert(!header.IsNull());
|
||||
uint256 hash = header.GetHash();
|
||||
block = header;
|
||||
|
|
@ -197,7 +203,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
|
|||
return READ_STATUS_INVALID;
|
||||
|
||||
CValidationState state;
|
||||
if (!CheckBlock(block, state, Params().GetConsensus())) {
|
||||
if (!CheckBlock(block, state, Params().GetConsensus(), check_pow)) {
|
||||
// TODO: We really want to just check merkle tree manually here,
|
||||
// but that is expensive, and CheckBlock caches a block's
|
||||
// "checked-status" (in the CBlock?). CBlock should be able to
|
||||
|
|
|
|||
|
|
@ -200,10 +200,11 @@ public:
|
|||
CBlockHeader header;
|
||||
explicit PartiallyDownloadedBlock(CTxMemPool* poolIn) : pool(poolIn) {}
|
||||
|
||||
std::vector<CTransactionRef> GetAvailableTx();
|
||||
// extra_txn is a list of extra transactions to look at, in <witness hash, reference> form
|
||||
ReadStatus InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector<std::pair<uint256, CTransactionRef>>& extra_txn);
|
||||
bool IsTxAvailable(size_t index) const;
|
||||
ReadStatus FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing);
|
||||
ReadStatus FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing, bool check_pow = true);
|
||||
};
|
||||
|
||||
#endif // BITCOIN_BLOCKENCODINGS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue