MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / PeriodicFlush

Method PeriodicFlush

src/wallet/db.cpp:706–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

704}
705
706bool BerkeleyBatch::PeriodicFlush(BerkeleyDatabase& database)
707{
708 if (database.IsDummy()) {
709 return true;
710 }
711 bool ret = false;
712 BerkeleyEnvironment *env = database.env;
713 const std::string& strFile = database.strFile;
714 TRY_LOCK(cs_db, lockDb);
715 if (lockDb)
716 {
717 // Don't do this if any databases are in use
718 int nRefCount = 0;
719 std::map<std::string, int>::iterator mit = env->mapFileUseCount.begin();
720 while (mit != env->mapFileUseCount.end())
721 {
722 nRefCount += (*mit).second;
723 mit++;
724 }
725
726 if (nRefCount == 0)
727 {
728 boost::this_thread::interruption_point();
729 std::map<std::string, int>::iterator mi = env->mapFileUseCount.find(strFile);
730 if (mi != env->mapFileUseCount.end())
731 {
732 LogPrint(BCLog::DB, "Flushing %s\n", strFile);
733 int64_t nStart = GetTimeMillis();
734
735 // Flush wallet file so it's self contained
736 env->CloseDb(strFile);
737 env->CheckpointLSN(strFile);
738
739 env->mapFileUseCount.erase(mi++);
740 LogPrint(BCLog::DB, "Flushed %s %dms\n", strFile, GetTimeMillis() - nStart);
741 ret = true;
742 }
743 }
744 }
745
746 return ret;
747}
748
749bool BerkeleyDatabase::Rewrite(const char* pszSkip)
750{

Callers

nothing calls this directly

Calls 8

GetTimeMillisFunction · 0.85
IsDummyMethod · 0.80
CloseDbMethod · 0.80
CheckpointLSNMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected