| 576 | } |
| 577 | |
| 578 | bool 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 | |
| 605 | bool BerkeleyDatabase::Backup(const std::string& strDest) const |
| 606 | { |
no test coverage detected