Closed dooglus closed 9 years ago
I was seeing a -rescan take many hours, when previously it was faster.
I traced the problem to this code in wallet.cpp:
BOOST_FOREACH(const CTxOut& txout, tx.vout) { if (IsMine(txout)) { wtx.MarkUnspent(&txout - &tx.vout[0]); wtx.WriteToDisk(); NotifyTransactionChanged(this, hash, CT_UPDATED); } }
it is writing the same potentially large transaction to the wallet database over and over if multiple outputs belong to us.
http://khashier.com/tx/206455f7636bbef3e1161f5d2a595a8787a58056adf2966039fcafdae7fb3d17#i0 was particularly slow - the above loop takes almost 3 minutes to run on that one transaction as it writes the same tx to disk ~1000 times.
How about replacing with something like this?
bool fMine = false; BOOST_FOREACH(const CTxOut& txout, tx.vout) { if (IsMine(txout)) { wtx.MarkUnspent(&txout - &tx.vout[0]); fMine = true; } } if (fMine) { wtx.WriteToDisk(); NotifyTransactionChanged(this, hash, CT_UPDATED); }
Is it safe?
Fixed in #157.
I was seeing a -rescan take many hours, when previously it was faster.
I traced the problem to this code in wallet.cpp:
it is writing the same potentially large transaction to the wallet database over and over if multiple outputs belong to us.
http://khashier.com/tx/206455f7636bbef3e1161f5d2a595a8787a58056adf2966039fcafdae7fb3d17#i0 was particularly slow - the above loop takes almost 3 minutes to run on that one transaction as it writes the same tx to disk ~1000 times.
How about replacing with something like this?
Is it safe?