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

Function MaybeCompactWalletDB

src/wallet/walletdb.cpp:1128–1153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126}
1127
1128void MaybeCompactWalletDB(WalletContext& context)
1129{
1130 static std::atomic<bool> fOneThread(false);
1131 if (fOneThread.exchange(true)) {
1132 return;
1133 }
1134
1135 for (const std::shared_ptr<CWallet>& pwallet : GetWallets(context)) {
1136 WalletDatabase& dbh = pwallet->GetDatabase();
1137
1138 unsigned int nUpdateCounter = dbh.nUpdateCounter;
1139
1140 if (dbh.nLastSeen != nUpdateCounter) {
1141 dbh.nLastSeen = nUpdateCounter;
1142 dbh.nLastWalletUpdate = GetTime();
1143 }
1144
1145 if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) {
1146 if (dbh.PeriodicFlush()) {
1147 dbh.nLastFlushed = nUpdateCounter;
1148 }
1149 }
1150 }
1151
1152 fOneThread = false;
1153}
1154
1155bool WalletBatch::WriteDestData(const std::string &address, const std::string &key, const std::string &value)
1156{

Callers 1

StartWalletsFunction · 0.85

Calls 3

GetWalletsFunction · 0.85
GetTimeFunction · 0.85
PeriodicFlushMethod · 0.45

Tested by

no test coverage detected