aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r--src/txdb.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp
index d3d05c58d7..7c0683aaf3 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -54,12 +54,15 @@ bool CCoinsViewDB::SetBestBlock(const uint256 &hashBlock) {
return db.WriteBatch(batch);
}
-bool CCoinsViewDB::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock) {
+bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) {
LogPrint("coindb", "Committing %u changed transactions to coin database...\n", (unsigned int)mapCoins.size());
CLevelDBBatch batch;
- for (CCoinsMap::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++)
+ for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) {
BatchWriteCoins(batch, it->first, it->second);
+ CCoinsMap::iterator itOld = it++;
+ mapCoins.erase(itOld);
+ }
if (hashBlock != uint256(0))
BatchWriteHashBestChain(batch, hashBlock);