@@ -24,7 +24,7 @@ CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block, bool f
2424 // TODO: Use our mempool prior to block acceptance to predictively fill more than just the coinbase
2525 prefilledtxn[0 ] = {0 , block.vtx [0 ]};
2626 for (size_t i = 1 ; i < block.vtx .size (); i++) {
27- const CTransaction& tx = block.vtx [i];
27+ const CTransaction& tx = * block.vtx [i];
2828 shorttxids[i - 1 ] = GetShortID (fUseWTXID ? tx.GetWitnessHash () : tx.GetHash ());
2929 }
3030}
@@ -59,7 +59,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
5959
6060 int32_t lastprefilledindex = -1 ;
6161 for (size_t i = 0 ; i < cmpctblock.prefilledtxn .size (); i++) {
62- if (cmpctblock.prefilledtxn [i].tx . IsNull ())
62+ if (cmpctblock.prefilledtxn [i].tx -> IsNull ())
6363 return READ_STATUS_INVALID;
6464
6565 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
7171 // have neither a prefilled txn or a shorttxid!
7272 return READ_STATUS_INVALID;
7373 }
74- txn_available[lastprefilledindex] = std::make_shared<CTransaction>( cmpctblock.prefilledtxn [i].tx ) ;
74+ txn_available[lastprefilledindex] = cmpctblock.prefilledtxn [i].tx ;
7575 }
7676 prefilled_count = cmpctblock.prefilledtxn .size ();
7777
@@ -142,7 +142,7 @@ bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
142142 return txn_available[index] ? true : false ;
143143}
144144
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 {
146146 assert (!header.IsNull ());
147147 block = header;
148148 block.vtx .resize (txn_available.size ());
@@ -154,7 +154,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
154154 return READ_STATUS_INVALID;
155155 block.vtx [i] = vtx_missing[tx_missing_offset++];
156156 } else
157- block.vtx [i] = * txn_available[i];
157+ block.vtx [i] = txn_available[i];
158158 }
159159 if (vtx_missing.size () != tx_missing_offset)
160160 return READ_STATUS_INVALID;
@@ -172,8 +172,8 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
172172
173173 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 ());
174174 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 ());
177177 }
178178
179179 return READ_STATUS_OK;
0 commit comments