Skip to content

Commit

Permalink
Add receivedFinalCommitment flag to CDKGDebugSessionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jan 21, 2019
1 parent 23d7ed8 commit 0cc1cf2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/llmq/quorums_blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "quorums_blockprocessor.h"
#include "quorums_commitment.h"
#include "quorums_debug.h"
#include "quorums_utils.h"

#include "evo/specialtx.h"
Expand Down Expand Up @@ -336,6 +337,14 @@ void CQuorumBlockProcessor::AddMinableCommitment(const CFinalCommitment& fqc)
}
}

quorumDKGDebugManager->UpdateLocalSessionStatus((Consensus::LLMQType)fqc.llmqType, [&](CDKGDebugSessionStatus& status) {
if (status.quorumHash != fqc.quorumHash || status.receivedFinalCommitment) {
return false;
}
status.receivedFinalCommitment = true;
return true;
});

// We only relay the new commitment if it's new or better then the old one
if (relay) {
CInv inv(MSG_QUORUM_FINAL_COMMITMENT, commitmentHash);
Expand Down
2 changes: 2 additions & 0 deletions src/llmq/quorums_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ UniValue CDKGDebugSessionStatus::ToJson(int detailLevel) const
push(receivedComplaints, "receivedComplaints");
push(receivedJustifications, "receivedJustifications");
push(receivedPrematureCommitments, "receivedPrematureCommitments");
ret.push_back(Pair("receivedFinalCommitment", receivedFinalCommitment));

if (detailLevel == 2) {
UniValue arr(UniValue::VARR);
Expand Down Expand Up @@ -296,6 +297,7 @@ void CDKGDebugManager::ResetLocalSessionStatus(Consensus::LLMQType llmqType, con
session.statusBitset = 0;
session.members.clear();
session.members.resize((size_t)params.size);
session.receivedFinalCommitment = false;
}

void CDKGDebugManager::UpdateLocalStatus(std::function<bool(CDKGDebugStatus& status)>&& func)
Expand Down
2 changes: 2 additions & 0 deletions src/llmq/quorums_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CDKGDebugSessionStatus
};

std::vector<CDKGDebugMemberStatus> members;
bool receivedFinalCommitment{false};

public:
CDKGDebugSessionStatus() : statusBitset(0) {}
Expand All @@ -94,6 +95,7 @@ class CDKGDebugSessionStatus
READWRITE(phase);
READWRITE(statusBitset);
READWRITE(members);
READWRITE(receivedFinalCommitment);
}

UniValue ToJson(int detailLevel) const;
Expand Down

0 comments on commit 0cc1cf2

Please sign in to comment.