MCPcopy Create free account
hub / github.com/ElementsProject/elements / PeriodicFlush

Method PeriodicFlush

src/wallet/bdb.cpp:578–603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

576}
577
578bool BerkeleyDatabase::PeriodicFlush()
579{
580 // Don't flush if we can't acquire the lock.
581 TRY_LOCK(cs_db, lockDb);
582 if (!lockDb) return false;
583
584 // Don't flush if any databases are in use
585 for (auto& it : env->m_databases) {
586 if (it.second.get().m_refcount > 0) return false;
587 }
588
589 // Don't flush if there haven't been any batch writes for this database.
590 if (m_refcount < 0) return false;
591
592 LogPrint(BCLog::WALLETDB, "Flushing %s\n", strFile);
593 int64_t nStart = GetTimeMillis();
594
595 // Flush wallet file so it's self contained
596 env->CloseDb(strFile);
597 env->CheckpointLSN(strFile);
598 m_refcount = -1;
599
600 LogPrint(BCLog::WALLETDB, "Flushed %s %dms\n", strFile, GetTimeMillis() - nStart);
601
602 return true;
603}
604
605bool BerkeleyDatabase::Backup(const std::string& strDest) const
606{

Callers 1

MaybeCompactWalletDBFunction · 0.45

Calls 4

GetTimeMillisFunction · 0.85
CloseDbMethod · 0.80
CheckpointLSNMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected