Skip to content

Commit

Permalink
Move RebuildSigShare from CBatchedSigShares to CSigSharesManager
Browse files Browse the repository at this point in the history
Needed as CBatchedSigShares doesn't have the necessary info anymore
  • Loading branch information
codablock committed Feb 27, 2019
1 parent 55a6182 commit 7372f6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
17 changes: 16 additions & 1 deletion src/llmq/quorums_signing_shares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void CSigSharesManager::ProcessMessageBatchedSigShares(CNode* pfrom, const CBatc
auto& nodeState = nodeStates[pfrom->id];

for (size_t i = 0; i < batchedSigShares.sigShares.size(); i++) {
CSigShare sigShare = batchedSigShares.RebuildSigShare(i);
CSigShare sigShare = RebuildSigShare(sessionInfo, batchedSigShares, i);
nodeState.requestedSigShares.Erase(sigShare.GetKey());

// TODO track invalid sig shares received for PoSe?
Expand Down Expand Up @@ -980,6 +980,21 @@ bool CSigSharesManager::SendMessages()
return didSend;
}

CSigShare CSigSharesManager::RebuildSigShare(const CSigSharesNodeState::SessionInfo& session, const CBatchedSigShares& batchedSigShares, size_t idx)
{
assert(idx < batchedSigShares.sigShares.size());
auto& s = batchedSigShares.sigShares[idx];
CSigShare sigShare;
sigShare.llmqType = session.llmqType;
sigShare.quorumHash = session.quorumHash;
sigShare.quorumMember = s.first;
sigShare.id = session.id;
sigShare.msgHash = session.msgHash;
sigShare.sigShare = s.second;
sigShare.UpdateKey();
return sigShare;
}

void CSigSharesManager::Cleanup()
{
int64_t now = GetTimeMillis();
Expand Down
17 changes: 2 additions & 15 deletions src/llmq/quorums_signing_shares.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,6 @@ class CBatchedSigShares
READWRITE(sigShares);
}

CSigShare RebuildSigShare(size_t idx) const
{
assert(idx < sigShares.size());
auto& s = sigShares[idx];
CSigShare sigShare;
sigShare.llmqType = llmqType;
sigShare.quorumHash = quorumHash;
sigShare.quorumMember = s.first;
sigShare.id = id;
sigShare.msgHash = msgHash;
sigShare.sigShare = s.second;
sigShare.UpdateKey();
return sigShare;
}

CSigSharesInv ToInv(Consensus::LLMQType llmqType) const;
};

Expand Down Expand Up @@ -392,6 +377,8 @@ class CSigSharesManager : public CRecoveredSigsListener
void TryRecoverSig(const CQuorumCPtr& quorum, const uint256& id, const uint256& msgHash, CConnman& connman);

private:
CSigShare RebuildSigShare(const CSigSharesNodeState::SessionInfo& session, const CBatchedSigShares& batchedSigShares, size_t idx);

void Cleanup();
void RemoveSigSharesForSession(const uint256& signHash);
void RemoveBannedNodeStates();
Expand Down

0 comments on commit 7372f6f

Please sign in to comment.