Skip to content

Commit

Permalink
Merge dashpay#6509: refactor: use more structured bindings
Browse files Browse the repository at this point in the history
fb0b5ac refactor: use more structured bindings (Pasta)

Pull request description:

  ## Issue being fixed or feature implemented
  We should use structured bindings where possible

  ## What was done?
  Use them

  ## How Has This Been Tested?
  Compiled

  ## Breaking Changes
  None

  ## Checklist:
    _Go over all the following points, and put an `x` in all the boxes that apply._
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK fb0b5ac

Tree-SHA512: 6b071de17e93ffb3f4c9d8d4959fa6e917d096b2b6b84125b69dd55cdebe2a641a50dbf4b6d4ce306ae17cee790d6675280aecdac71ed3f7b355a09d146ae12d
  • Loading branch information
PastaPastaPasta committed Dec 26, 2024
2 parents 941e04e + fb0b5ac commit af43eaf
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/llmq/dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,24 +367,22 @@ std::set<NodeId> BatchVerifyMessageSigs(CDKGSession& session, const std::vector<
pubKeys.reserve(messages.size());
messageHashes.reserve(messages.size());
bool first = true;
for (const auto& p : messages ) {
const auto& msg = *p.second;

auto member = session.GetMember(msg.proTxHash);
for (const auto& [nodeId, msg] : messages) {
auto member = session.GetMember(msg->proTxHash);
if (!member) {
// should not happen as it was verified before
ret.emplace(p.first);
ret.emplace(nodeId);
continue;
}

if (first) {
aggSig = msg.sig;
aggSig = msg->sig;
} else {
aggSig.AggregateInsecure(msg.sig);
aggSig.AggregateInsecure(msg->sig);
}
first = false;

auto msgHash = msg.GetSignHash();
auto msgHash = msg->GetSignHash();
if (!messageHashesSet.emplace(msgHash).second) {
// can only happen in 2 cases:
// 1. Someone sent us the same message twice but with differing signature, meaning that at least one of them
Expand Down Expand Up @@ -418,16 +416,15 @@ std::set<NodeId> BatchVerifyMessageSigs(CDKGSession& session, const std::vector<
// different nodes, let's figure out who are the bad ones
}

for (const auto& p : messages) {
if (ret.count(p.first)) {
for (const auto& [nodeId, msg] : messages) {
if (ret.count(nodeId)) {
continue;
}

const auto& msg = *p.second;
auto member = session.GetMember(msg.proTxHash);
bool valid = msg.sig.VerifyInsecure(member->dmn->pdmnState->pubKeyOperator.Get(), msg.GetSignHash());
auto member = session.GetMember(msg->proTxHash);
bool valid = msg->sig.VerifyInsecure(member->dmn->pdmnState->pubKeyOperator.Get(), msg->GetSignHash());
if (!valid) {
ret.emplace(p.first);
ret.emplace(nodeId);
}
}
return ret;
Expand Down

0 comments on commit af43eaf

Please sign in to comment.