@@ -24,7 +24,7 @@ CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block, bool f
24
24
// TODO: Use our mempool prior to block acceptance to predictively fill more than just the coinbase
25
25
prefilledtxn[0 ] = {0 , block.vtx [0 ]};
26
26
for (size_t i = 1 ; i < block.vtx .size (); i++) {
27
- const CTransaction& tx = block.vtx [i];
27
+ const CTransaction& tx = * block.vtx [i];
28
28
shorttxids[i - 1 ] = GetShortID (fUseWTXID ? tx.GetWitnessHash () : tx.GetHash ());
29
29
}
30
30
}
@@ -59,7 +59,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
59
59
60
60
int32_t lastprefilledindex = -1 ;
61
61
for (size_t i = 0 ; i < cmpctblock.prefilledtxn .size (); i++) {
62
- if (cmpctblock.prefilledtxn [i].tx . IsNull ())
62
+ if (cmpctblock.prefilledtxn [i].tx -> IsNull ())
63
63
return READ_STATUS_INVALID;
64
64
65
65
lastprefilledindex += cmpctblock.prefilledtxn [i].index + 1 ; // index is a uint16_t, so cant overflow here
@@ -71,7 +71,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
71
71
// have neither a prefilled txn or a shorttxid!
72
72
return READ_STATUS_INVALID;
73
73
}
74
- txn_available[lastprefilledindex] = std::make_shared<CTransaction>( cmpctblock.prefilledtxn [i].tx ) ;
74
+ txn_available[lastprefilledindex] = cmpctblock.prefilledtxn [i].tx ;
75
75
}
76
76
prefilled_count = cmpctblock.prefilledtxn .size ();
77
77
@@ -142,7 +142,7 @@ bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
142
142
return txn_available[index] ? true : false ;
143
143
}
144
144
145
- ReadStatus PartiallyDownloadedBlock::FillBlock (CBlock& block, const std::vector<CTransaction>& vtx_missing) const {
145
+ ReadStatus PartiallyDownloadedBlock::FillBlock (CBlock& block, const std::vector<std::shared_ptr< const CTransaction> >& vtx_missing) const {
146
146
assert (!header.IsNull ());
147
147
block = header;
148
148
block.vtx .resize (txn_available.size ());
@@ -154,7 +154,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
154
154
return READ_STATUS_INVALID;
155
155
block.vtx [i] = vtx_missing[tx_missing_offset++];
156
156
} else
157
- block.vtx [i] = * txn_available[i];
157
+ block.vtx [i] = txn_available[i];
158
158
}
159
159
if (vtx_missing.size () != tx_missing_offset)
160
160
return READ_STATUS_INVALID;
@@ -172,8 +172,8 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
172
172
173
173
LogPrint (" cmpctblock" , " Successfully reconstructed block %s with %lu txn prefilled, %lu txn from mempool and %lu txn requested\n " , header.GetHash ().ToString (), prefilled_count, mempool_count, vtx_missing.size ());
174
174
if (vtx_missing.size () < 5 ) {
175
- for (const CTransaction & tx : vtx_missing)
176
- LogPrint (" cmpctblock" , " Reconstructed block %s required tx %s\n " , header.GetHash ().ToString (), tx. GetHash ().ToString ());
175
+ for (const auto & tx : vtx_missing)
176
+ LogPrint (" cmpctblock" , " Reconstructed block %s required tx %s\n " , header.GetHash ().ToString (), tx-> GetHash ().ToString ());
177
177
}
178
178
179
179
return READ_STATUS_OK;
0 commit comments