@@ -1256,7 +1256,7 @@ enum DisconnectResult
12561256 * @param out The out point that corresponds to the tx input.
12571257 * @return A DisconnectResult as an int
12581258 */
1259- int ApplyTxInUndo (const Coin& undo, CCoinsViewCache& view, const COutPoint& out)
1259+ int ApplyTxInUndo (Coin& & undo, CCoinsViewCache& view, const COutPoint& out)
12601260{
12611261 bool fClean = true ;
12621262
@@ -1277,7 +1277,7 @@ int ApplyTxInUndo(const Coin& undo, CCoinsViewCache& view, const COutPoint& out)
12771277 if (coins->IsAvailable (out.n )) fClean = false ; // overwriting existing output
12781278 if (coins->vout .size () < out.n +1 )
12791279 coins->vout .resize (out.n +1 );
1280- coins->vout [out.n ] = undo.out ;
1280+ coins->vout [out.n ] = std::move ( undo.out ) ;
12811281
12821282 return fClean ? DISCONNECT_OK : DISCONNECT_UNCLEAN;
12831283}
@@ -1326,18 +1326,18 @@ static DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex*
13261326
13271327 // restore inputs
13281328 if (i > 0 ) { // not coinbases
1329- const CTxUndo &txundo = blockUndo.vtxundo [i-1 ];
1329+ CTxUndo &txundo = blockUndo.vtxundo [i-1 ];
13301330 if (txundo.vprevout .size () != tx.vin .size ()) {
13311331 error (" DisconnectBlock(): transaction and undo data inconsistent" );
13321332 return DISCONNECT_FAILED;
13331333 }
13341334 for (unsigned int j = tx.vin .size (); j-- > 0 ;) {
13351335 const COutPoint &out = tx.vin [j].prevout ;
1336- const Coin &undo = txundo.vprevout [j];
1337- int res = ApplyTxInUndo (undo, view, out);
1336+ int res = ApplyTxInUndo (std::move (txundo.vprevout [j]), view, out);
13381337 if (res == DISCONNECT_FAILED) return DISCONNECT_FAILED;
13391338 fClean = fClean && res != DISCONNECT_UNCLEAN;
13401339 }
1340+ // At this point, all of txundo.vprevout should have been moved out.
13411341 }
13421342 }
13431343
0 commit comments