@@ -1256,7 +1256,7 @@ enum DisconnectResult
1256
1256
* @param out The out point that corresponds to the tx input.
1257
1257
* @return A DisconnectResult as an int
1258
1258
*/
1259
- int ApplyTxInUndo (const Coin& undo, CCoinsViewCache& view, const COutPoint& out)
1259
+ int ApplyTxInUndo (Coin& & undo, CCoinsViewCache& view, const COutPoint& out)
1260
1260
{
1261
1261
bool fClean = true ;
1262
1262
@@ -1277,7 +1277,7 @@ int ApplyTxInUndo(const Coin& undo, CCoinsViewCache& view, const COutPoint& out)
1277
1277
if (coins->IsAvailable (out.n )) fClean = false ; // overwriting existing output
1278
1278
if (coins->vout .size () < out.n +1 )
1279
1279
coins->vout .resize (out.n +1 );
1280
- coins->vout [out.n ] = undo.out ;
1280
+ coins->vout [out.n ] = std::move ( undo.out ) ;
1281
1281
1282
1282
return fClean ? DISCONNECT_OK : DISCONNECT_UNCLEAN;
1283
1283
}
@@ -1326,18 +1326,18 @@ static DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex*
1326
1326
1327
1327
// restore inputs
1328
1328
if (i > 0 ) { // not coinbases
1329
- const CTxUndo &txundo = blockUndo.vtxundo [i-1 ];
1329
+ CTxUndo &txundo = blockUndo.vtxundo [i-1 ];
1330
1330
if (txundo.vprevout .size () != tx.vin .size ()) {
1331
1331
error (" DisconnectBlock(): transaction and undo data inconsistent" );
1332
1332
return DISCONNECT_FAILED;
1333
1333
}
1334
1334
for (unsigned int j = tx.vin .size (); j-- > 0 ;) {
1335
1335
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);
1338
1337
if (res == DISCONNECT_FAILED) return DISCONNECT_FAILED;
1339
1338
fClean = fClean && res != DISCONNECT_UNCLEAN;
1340
1339
}
1340
+ // At this point, all of txundo.vprevout should have been moved out.
1341
1341
}
1342
1342
}
1343
1343
0 commit comments