refactor: use try_emplace over emplace

This commit is contained in:
pasta 2023-12-17 13:08:44 -06:00
parent b6907d2bea
commit 66351aaaf9
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -653,9 +653,9 @@ void CQuorumBlockProcessor::AddMineableCommitment(const CFinalCommitment& fqc)
LOCK(minableCommitmentsCs);
auto k = std::make_pair(fqc.llmqType, fqc.quorumHash);
auto ins = minableCommitmentsByQuorum.emplace(k, commitmentHash);
auto ins = minableCommitmentsByQuorum.try_emplace(k, commitmentHash);
if (ins.second) {
minableCommitments.emplace(commitmentHash, fqc);
minableCommitments.try_emplace(commitmentHash, fqc);
relay = true;
} else {
const auto& oldFqc = minableCommitments.at(ins.first->second);
@ -663,7 +663,7 @@ void CQuorumBlockProcessor::AddMineableCommitment(const CFinalCommitment& fqc)
// new commitment has more signers, so override the known one
ins.first->second = commitmentHash;
minableCommitments.erase(ins.first->second);
minableCommitments.emplace(commitmentHash, fqc);
minableCommitments.try_emplace(commitmentHash, fqc);
relay = true;
}
}