Skip to content

Commit 7aa0a48

Browse files
committed
use emplace instead of find+[], erase entries once locked
1 parent ec533ac commit 7aa0a48

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/llmq/instantsend.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,13 +1192,8 @@ void CInstantSendManager::AddNonLockedTx(const CTransactionRef& tx, const CBlock
11921192
}
11931193
}
11941194

1195-
{
1196-
LOCK(cs_timingsTxSeen);
1197-
// Only insert the time the first time we see the tx, as we sometimes try to resign
1198-
if (auto it = timingsTxSeen.find(tx->GetHash()); it == timingsTxSeen.end()) {
1199-
timingsTxSeen[tx->GetHash()] = GetTimeMillis();
1200-
}
1201-
}
1195+
// Only insert the time the first time we see the tx, as we sometimes try to resign
1196+
WITH_LOCK(cs_timingsTxSeen, timingsTxSeen.emplace(tx->GetHash(), GetTimeMillis()));
12021197

12031198
LogPrint(BCLog::INSTANTSEND, "CInstantSendManager::%s -- txid=%s, pindexMined=%s\n", __func__,
12041199
tx->GetHash().ToString(), pindexMined ? pindexMined->GetBlockHash().ToString() : "");
@@ -1240,6 +1235,8 @@ void CInstantSendManager::RemoveNonLockedTx(const uint256& txid, bool retryChild
12401235

12411236
nonLockedTxs.erase(it);
12421237

1238+
WITH_LOCK(cs_timingsTxSeen, timingsTxSeen.erase(txid));
1239+
12431240
LogPrint(BCLog::INSTANTSEND, "CInstantSendManager::%s -- txid=%s, retryChildren=%d, retryChildrenCount=%d\n", __func__,
12441241
txid.ToString(), retryChildren, retryChildrenCount);
12451242
}

0 commit comments

Comments
 (0)