diff --git a/src/Ledger.cpp b/src/Ledger.cpp index b21958e58c..7ee7e2689d 100644 --- a/src/Ledger.cpp +++ b/src/Ledger.cpp @@ -363,13 +363,9 @@ void Ledger::saveAcceptedLedger() { ScopedLock sl(theApp->getLedgerDB()->getDBLock()); + if (SQL_EXISTS(theApp->getLedgerDB()->getDB(), boost::str(ledgerExists % mLedgerSeq))) theApp->getLedgerDB()->getDB()->executeSQL(boost::str(deleteLedger % mLedgerSeq)); - theApp->getLedgerDB()->getDB()->executeSQL(boost::str(addLedger % - getHash().GetHex() % mLedgerSeq % mParentHash.GetHex() % - boost::lexical_cast(mTotCoins) % mCloseTime % mParentCloseTime % - mCloseResolution % mCloseFlags % - mAccountHash.GetHex() % mTransHash.GetHex())); // write out dirty nodes int fc; @@ -379,6 +375,12 @@ void Ledger::saveAcceptedLedger() { cLog(lsINFO) << "Flushed " << fc << " dirty state nodes"; } disarmDirty(); + theApp->getLedgerDB()->getDB()->executeSQL(boost::str(addLedger % + getHash().GetHex() % mLedgerSeq % mParentHash.GetHex() % + boost::lexical_cast(mTotCoins) % mCloseTime % mParentCloseTime % + mCloseResolution % mCloseFlags % + mAccountHash.GetHex() % mTransHash.GetHex())); + SHAMap& txSet = *peekTransactionMap(); Database *db = theApp->getTxnDB()->getDB(); ScopedLock dbLock = theApp->getTxnDB()->getDBLock();