ISDB avoid processing the same fully confirmed block in DB multiple times (#4193)

This commit is contained in:
PastaPastaPasta 2021-07-01 15:43:39 -05:00 committed by GitHub
parent 49ebff2702
commit 2125805a31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -161,9 +161,12 @@ void CInstantSendDb::WriteInstantSendLockArchived(CDBBatch& batch, const uint256
std::unordered_map<uint256, CInstantSendLockPtr> CInstantSendDb::RemoveConfirmedInstantSendLocks(int nUntilHeight)
{
if (nUntilHeight <= 0) {
if (nUntilHeight <= best_confirmed_height) {
LogPrint(BCLog::ALL, "CInstantSendDb::%s -- Attempting to confirm height %d, however we've already confirmed height %d. This should never happen.\n", __func__,
nUntilHeight, best_confirmed_height);
return {};
}
best_confirmed_height = nUntilHeight;
auto it = std::unique_ptr<CDBIterator>(db.NewIterator());

View File

@ -42,6 +42,8 @@ class CInstantSendDb
private:
static const int CURRENT_VERSION = 1;
int best_confirmed_height{0};
CDBWrapper& db;
mutable unordered_lru_cache<uint256, CInstantSendLockPtr, StaticSaltedHasher, 10000> islockCache;