| 1126 | } |
| 1127 | |
| 1128 | void 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 | |
| 1155 | bool WalletBatch::WriteDestData(const std::string &address, const std::string &key, const std::string &value) |
| 1156 | { |
no test coverage detected