mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
refactor: create a immediately executed llamda; use some structed bindings inside of ti
This commit is contained in:
parent
1af51b2004
commit
c2ac444abf
@ -646,28 +646,29 @@ bool CQuorumBlockProcessor::HasMineableCommitment(const uint256& hash) const
|
||||
|
||||
void CQuorumBlockProcessor::AddMineableCommitment(const CFinalCommitment& fqc)
|
||||
{
|
||||
bool relay = false;
|
||||
uint256 commitmentHash = ::SerializeHash(fqc);
|
||||
const uint256 commitmentHash = ::SerializeHash(fqc);
|
||||
|
||||
{
|
||||
const bool relay = [&]() {
|
||||
LOCK(minableCommitmentsCs);
|
||||
|
||||
auto k = std::make_pair(fqc.llmqType, fqc.quorumHash);
|
||||
auto ins = minableCommitmentsByQuorum.try_emplace(k, commitmentHash);
|
||||
if (ins.second) {
|
||||
auto [itInserted, successfullyInserted] = minableCommitmentsByQuorum.try_emplace(k, commitmentHash);
|
||||
if (successfullyInserted) {
|
||||
minableCommitments.try_emplace(commitmentHash, fqc);
|
||||
relay = true;
|
||||
return true;
|
||||
} else {
|
||||
const auto& oldFqc = minableCommitments.at(ins.first->second);
|
||||
auto& insertedQuorumHash = itInserted->second;
|
||||
const auto& oldFqc = minableCommitments.at(insertedQuorumHash);
|
||||
if (fqc.CountSigners() > oldFqc.CountSigners()) {
|
||||
// new commitment has more signers, so override the known one
|
||||
ins.first->second = commitmentHash;
|
||||
minableCommitments.erase(ins.first->second);
|
||||
insertedQuorumHash = commitmentHash;
|
||||
minableCommitments.erase(insertedQuorumHash);
|
||||
minableCommitments.try_emplace(commitmentHash, fqc);
|
||||
relay = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
|
||||
// We only relay the new commitment if it's new or better then the old one
|
||||
if (relay) {
|
||||
|
Loading…
Reference in New Issue
Block a user