PIVX Core  5.6.99
P2P Digital Currency
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
llmq::CSigSharesManager Class Reference

#include <quorums_signing_shares.h>

Inheritance diagram for llmq::CSigSharesManager:
[legend]
Collaboration diagram for llmq::CSigSharesManager:
[legend]

Public Member Functions

 CSigSharesManager ()
 
 ~CSigSharesManager ()
 
void StartWorkerThread ()
 
void StopWorkerThread ()
 
void Interrupt ()
 
void RegisterAsRecoveredSigsListener ()
 
void UnregisterAsRecoveredSigsListener ()
 
void ProcessMessage (CNode *pnode, const std::string &strCommand, CDataStream &vRecv, CConnman &connman)
 
void AsyncSign (const CQuorumCPtr &quorum, const uint256 &id, const uint256 &msgHash)
 
void Sign (const CQuorumCPtr &quorum, const uint256 &id, const uint256 &msgHash)
 
void ForceReAnnouncement (const CQuorumCPtr &quorum, Consensus::LLMQType llmqType, const uint256 &id, const uint256 &msgHash)
 
void HandleNewRecoveredSig (const CRecoveredSig &recoveredSig)
 
- Public Member Functions inherited from llmq::CRecoveredSigsListener
virtual ~CRecoveredSigsListener ()
 

Static Public Member Functions

static CDeterministicMNCPtr SelectMemberForRecovery (const CQuorumCPtr &quorum, const uint256 &id, int attempt)
 

Private Member Functions

bool ProcessMessageSigSesAnn (CNode *pfrom, const CSigSesAnn &ann, CConnman &connman)
 
bool ProcessMessageSigSharesInv (CNode *pfrom, const CSigSharesInv &inv, CConnman &connman)
 
bool ProcessMessageGetSigShares (CNode *pfrom, const CSigSharesInv &inv, CConnman &connman)
 
bool ProcessMessageBatchedSigShares (CNode *pfrom, const CBatchedSigShares &batchedSigShares, CConnman &connman)
 
void ProcessMessageSigShare (NodeId fromId, const CSigShare &sigShare, CConnman &connman)
 
bool VerifySigSharesInv (NodeId from, Consensus::LLMQType llmqType, const CSigSharesInv &inv)
 
bool PreVerifyBatchedSigShares (NodeId nodeId, const CSigSharesNodeState::SessionInfo &session, const CBatchedSigShares &batchedSigShares, bool &retBan)
 
void CollectPendingSigSharesToVerify (size_t maxUniqueSessions, std::unordered_map< NodeId, std::vector< CSigShare >> &retSigShares, std::unordered_map< std::pair< Consensus::LLMQType, uint256 >, CQuorumCPtr, StaticSaltedHasher > &retQuorums)
 
bool ProcessPendingSigShares (CConnman &connman)
 
void ProcessPendingSigSharesFromNode (NodeId nodeId, const std::vector< CSigShare > &sigShares, const std::unordered_map< std::pair< Consensus::LLMQType, uint256 >, CQuorumCPtr, StaticSaltedHasher > &quorums, CConnman &connman)
 
void ProcessSigShare (NodeId nodeId, const CSigShare &sigShare, CConnman &connman, const CQuorumCPtr &quorum)
 
void TryRecoverSig (const CQuorumCPtr &quorum, const uint256 &id, const uint256 &msgHash, CConnman &connman)
 
bool GetSessionInfoByRecvId (NodeId nodeId, uint32_t sessionId, CSigSharesNodeState::SessionInfo &retInfo)
 
CSigShare RebuildSigShare (const CSigSharesNodeState::SessionInfo &session, const CBatchedSigShares &batchedSigShares, size_t idx)
 
void Cleanup ()
 
void RemoveSigSharesForSession (const uint256 &signHash)
 
void RemoveBannedNodeStates ()
 
void BanNode (NodeId nodeId)
 
bool SendMessages ()
 
void CollectSigSharesToRequest (std::unordered_map< NodeId, std::unordered_map< uint256, CSigSharesInv, StaticSaltedHasher >> &sigSharesToRequest)
 
void CollectSigSharesToSend (std::unordered_map< NodeId, std::unordered_map< uint256, CBatchedSigShares, StaticSaltedHasher >> &sigSharesToSend)
 
void CollectSigSharesToSend (std::unordered_map< NodeId, std::vector< CSigShare >> &sigSharesToSend, const std::vector< CNode * > &vNodes)
 
void CollectSigSharesToAnnounce (std::unordered_map< NodeId, std::unordered_map< uint256, CSigSharesInv, StaticSaltedHasher >> &sigSharesToAnnounce)
 
bool SignPendingSigShares ()
 
void WorkThreadMain ()
 

Private Attributes

const size_t MAX_MSGS_CNT_QSIGSESANN = 100
 
const size_t MAX_MSGS_CNT_QGETSIGSHARES = 200
 
const size_t MAX_MSGS_CNT_QSIGSHARESINV = 200
 
const size_t MAX_MSGS_TOTAL_BATCHED_SIGS = 400
 
const int64_t EXP_SEND_FOR_RECOVERY_TIMEOUT = 2000
 
const int64_t MAX_SEND_FOR_RECOVERY_TIMEOUT = 10000
 
const size_t MAX_MSGS_SIG_SHARES = 32
 
RecursiveMutex cs
 
std::thread workThread
 
CThreadInterrupt interruptSigningShare
 
SigShareMap< CSigSharesigShares
 
std::unordered_map< uint256, CSignedSession, StaticSaltedHashersignedSessions
 
std::unordered_map< uint256, int64_t, StaticSaltedHashertimeSeenForSessions
 
std::unordered_map< NodeId, CSigSharesNodeStatenodeStates
 
SigShareMap< std::pair< NodeId, int64_t > > sigSharesRequested
 
SigShareMap< bool > sigSharesToAnnounce
 
std::vector< std::tuple< const CQuorumCPtr, uint256, uint256 > > pendingSigns
 
FastRandomContext rnd
 
int64_t lastCleanupTime {0}
 
std::atomic< uint32_t > recoveredSigsCounter {0}
 

Static Private Attributes

static const int64_t SESSION_NEW_SHARES_TIMEOUT = 60
 
static const int64_t SIG_SHARE_REQUEST_TIMEOUT = 5
 

Detailed Description

Definition at line 342 of file quorums_signing_shares.h.

Constructor & Destructor Documentation

◆ CSigSharesManager()

llmq::CSigSharesManager::CSigSharesManager ( )

Definition at line 189 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ ~CSigSharesManager()

llmq::CSigSharesManager::~CSigSharesManager ( )

Definition at line 194 of file quorums_signing_shares.cpp.

Member Function Documentation

◆ AsyncSign()

void llmq::CSigSharesManager::AsyncSign ( const CQuorumCPtr quorum,
const uint256 id,
const uint256 msgHash 
)

Definition at line 1498 of file quorums_signing_shares.cpp.

◆ BanNode()

void llmq::CSigSharesManager::BanNode ( NodeId  nodeId)
private

Definition at line 1443 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cleanup()

void llmq::CSigSharesManager::Cleanup ( )
private

Definition at line 1283 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CollectPendingSigSharesToVerify()

void llmq::CSigSharesManager::CollectPendingSigSharesToVerify ( size_t  maxUniqueSessions,
std::unordered_map< NodeId, std::vector< CSigShare >> &  retSigShares,
std::unordered_map< std::pair< Consensus::LLMQType, uint256 >, CQuorumCPtr, StaticSaltedHasher > &  retQuorums 
)
private

Definition at line 569 of file quorums_signing_shares.cpp.

Here is the caller graph for this function:

◆ CollectSigSharesToAnnounce()

void llmq::CSigSharesManager::CollectSigSharesToAnnounce ( std::unordered_map< NodeId, std::unordered_map< uint256, CSigSharesInv, StaticSaltedHasher >> &  sigSharesToAnnounce)
private
Todo:
unused

Definition at line 1046 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ CollectSigSharesToRequest()

void llmq::CSigSharesManager::CollectSigSharesToRequest ( std::unordered_map< NodeId, std::unordered_map< uint256, CSigSharesInv, StaticSaltedHasher >> &  sigSharesToRequest)
private
Todo:
unused

Definition at line 856 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ CollectSigSharesToSend() [1/2]

void llmq::CSigSharesManager::CollectSigSharesToSend ( std::unordered_map< NodeId, std::unordered_map< uint256, CBatchedSigShares, StaticSaltedHasher >> &  sigSharesToSend)
private
Todo:
: unused

Definition at line 953 of file quorums_signing_shares.cpp.

Here is the caller graph for this function:

◆ CollectSigSharesToSend() [2/2]

void llmq::CSigSharesManager::CollectSigSharesToSend ( std::unordered_map< NodeId, std::vector< CSigShare >> &  sigSharesToSend,
const std::vector< CNode * > &  vNodes 
)
private

Definition at line 1005 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ ForceReAnnouncement()

void llmq::CSigSharesManager::ForceReAnnouncement ( const CQuorumCPtr quorum,
Consensus::LLMQType  llmqType,
const uint256 id,
const uint256 msgHash 
)

Definition at line 1569 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ GetSessionInfoByRecvId()

bool llmq::CSigSharesManager::GetSessionInfoByRecvId ( NodeId  nodeId,
uint32_t  sessionId,
CSigSharesNodeState::SessionInfo retInfo 
)
private

Definition at line 1262 of file quorums_signing_shares.cpp.

Here is the caller graph for this function:

◆ HandleNewRecoveredSig()

void llmq::CSigSharesManager::HandleNewRecoveredSig ( const CRecoveredSig recoveredSig)
virtual

Implements llmq::CRecoveredSigsListener.

Definition at line 1593 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ Interrupt()

void llmq::CSigSharesManager::Interrupt ( )

Definition at line 220 of file quorums_signing_shares.cpp.

◆ PreVerifyBatchedSigShares()

bool llmq::CSigSharesManager::PreVerifyBatchedSigShares ( NodeId  nodeId,
const CSigSharesNodeState::SessionInfo session,
const CBatchedSigShares batchedSigShares,
bool &  retBan 
)
private
Todo:
we should allow to ask other nodes for the quorum vvec if we missed it in the DKG

Definition at line 527 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessMessage()

void llmq::CSigSharesManager::ProcessMessage ( CNode pnode,
const std::string &  strCommand,
CDataStream vRecv,
CConnman connman 
)

Definition at line 225 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ ProcessMessageBatchedSigShares()

bool llmq::CSigSharesManager::ProcessMessageBatchedSigShares ( CNode pfrom,
const CBatchedSigShares batchedSigShares,
CConnman connman 
)
private
Todo:
track invalid sig shares received for PoSe?
Todo:
for PoSe, we should consider propagating shares even if we already have a recovered sig

Definition at line 421 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ ProcessMessageGetSigShares()

bool llmq::CSigSharesManager::ProcessMessageGetSigShares ( CNode pfrom,
const CSigSharesInv inv,
CConnman connman 
)
private
Todo:
for PoSe, we should consider propagating shares even if we already have a recovered sig

Definition at line 391 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ ProcessMessageSigSesAnn()

bool llmq::CSigSharesManager::ProcessMessageSigSesAnn ( CNode pfrom,
const CSigSesAnn ann,
CConnman connman 
)
private
Todo:
should we ban here?

Definition at line 310 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ ProcessMessageSigShare()

void llmq::CSigSharesManager::ProcessMessageSigShare ( NodeId  fromId,
const CSigShare sigShare,
CConnman connman 
)
private
Todo:
we should allow to ask other nodes for the quorum vvec if we missed it in the DKG

Definition at line 476 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessMessageSigSharesInv()

bool llmq::CSigSharesManager::ProcessMessageSigSharesInv ( CNode pfrom,
const CSigSharesInv inv,
CConnman connman 
)
private
Todo:
for PoSe, we should consider propagating shares even if we already have a recovered sig
Todo:
we should allow to ask other nodes for the quorum vvec if we missed it in the DKG

Definition at line 354 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ ProcessPendingSigShares()

bool llmq::CSigSharesManager::ProcessPendingSigShares ( CConnman connman)
private

Definition at line 628 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessPendingSigSharesFromNode()

void llmq::CSigSharesManager::ProcessPendingSigSharesFromNode ( NodeId  nodeId,
const std::vector< CSigShare > &  sigShares,
const std::unordered_map< std::pair< Consensus::LLMQType, uint256 >, CQuorumCPtr, StaticSaltedHasher > &  quorums,
CConnman connman 
)
private

Definition at line 702 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ ProcessSigShare()

void llmq::CSigSharesManager::ProcessSigShare ( NodeId  nodeId,
const CSigShare sigShare,
CConnman connman,
const CQuorumCPtr quorum 
)
private
Todo:
: unreachable

Definition at line 722 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RebuildSigShare()

CSigShare llmq::CSigSharesManager::RebuildSigShare ( const CSigSharesNodeState::SessionInfo session,
const CBatchedSigShares batchedSigShares,
size_t  idx 
)
private

Definition at line 1268 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterAsRecoveredSigsListener()

void llmq::CSigSharesManager::RegisterAsRecoveredSigsListener ( )

Definition at line 210 of file quorums_signing_shares.cpp.

◆ RemoveBannedNodeStates()

void llmq::CSigSharesManager::RemoveBannedNodeStates ( )
private

Definition at line 1424 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveSigSharesForSession()

void llmq::CSigSharesManager::RemoveSigSharesForSession ( const uint256 signHash)
private

Definition at line 1410 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SelectMemberForRecovery()

CDeterministicMNCPtr llmq::CSigSharesManager::SelectMemberForRecovery ( const CQuorumCPtr quorum,
const uint256 id,
int  attempt 
)
static

Definition at line 840 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendMessages()

bool llmq::CSigSharesManager::SendMessages ( )
private

Definition at line 1098 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sign()

void llmq::CSigSharesManager::Sign ( const CQuorumCPtr quorum,
const uint256 id,
const uint256 msgHash 
)

Definition at line 1519 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SignPendingSigShares()

bool llmq::CSigSharesManager::SignPendingSigShares ( )
private

Definition at line 1504 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartWorkerThread()

void llmq::CSigSharesManager::StartWorkerThread ( )

Definition at line 198 of file quorums_signing_shares.cpp.

Here is the call graph for this function:

◆ StopWorkerThread()

void llmq::CSigSharesManager::StopWorkerThread ( )

Definition at line 203 of file quorums_signing_shares.cpp.

◆ TryRecoverSig()

void llmq::CSigSharesManager::TryRecoverSig ( const CQuorumCPtr quorum,
const uint256 id,
const uint256 msgHash,
CConnman connman 
)
private

Definition at line 770 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnregisterAsRecoveredSigsListener()

void llmq::CSigSharesManager::UnregisterAsRecoveredSigsListener ( )

Definition at line 215 of file quorums_signing_shares.cpp.

◆ VerifySigSharesInv()

bool llmq::CSigSharesManager::VerifySigSharesInv ( NodeId  from,
Consensus::LLMQType  llmqType,
const CSigSharesInv inv 
)
private

Definition at line 344 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WorkThreadMain()

void llmq::CSigSharesManager::WorkThreadMain ( )
private
Todo:
Wakeup when pending signing is needed?

Definition at line 1470 of file quorums_signing_shares.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cs

RecursiveMutex llmq::CSigSharesManager::cs
private

Definition at line 359 of file quorums_signing_shares.h.

◆ EXP_SEND_FOR_RECOVERY_TIMEOUT

const int64_t llmq::CSigSharesManager::EXP_SEND_FOR_RECOVERY_TIMEOUT = 2000
private

Definition at line 354 of file quorums_signing_shares.h.

◆ interruptSigningShare

CThreadInterrupt llmq::CSigSharesManager::interruptSigningShare
private

Definition at line 362 of file quorums_signing_shares.h.

◆ lastCleanupTime

int64_t llmq::CSigSharesManager::lastCleanupTime {0}
private

Definition at line 379 of file quorums_signing_shares.h.

◆ MAX_MSGS_CNT_QGETSIGSHARES

const size_t llmq::CSigSharesManager::MAX_MSGS_CNT_QGETSIGSHARES = 200
private

Definition at line 349 of file quorums_signing_shares.h.

◆ MAX_MSGS_CNT_QSIGSESANN

const size_t llmq::CSigSharesManager::MAX_MSGS_CNT_QSIGSESANN = 100
private

Definition at line 348 of file quorums_signing_shares.h.

◆ MAX_MSGS_CNT_QSIGSHARESINV

const size_t llmq::CSigSharesManager::MAX_MSGS_CNT_QSIGSHARESINV = 200
private

Definition at line 350 of file quorums_signing_shares.h.

◆ MAX_MSGS_SIG_SHARES

const size_t llmq::CSigSharesManager::MAX_MSGS_SIG_SHARES = 32
private

Definition at line 356 of file quorums_signing_shares.h.

◆ MAX_MSGS_TOTAL_BATCHED_SIGS

const size_t llmq::CSigSharesManager::MAX_MSGS_TOTAL_BATCHED_SIGS = 400
private

Definition at line 352 of file quorums_signing_shares.h.

◆ MAX_SEND_FOR_RECOVERY_TIMEOUT

const int64_t llmq::CSigSharesManager::MAX_SEND_FOR_RECOVERY_TIMEOUT = 10000
private

Definition at line 355 of file quorums_signing_shares.h.

◆ nodeStates

std::unordered_map<NodeId, CSigSharesNodeState> llmq::CSigSharesManager::nodeStates
private

Definition at line 370 of file quorums_signing_shares.h.

◆ pendingSigns

std::vector<std::tuple<const CQuorumCPtr, uint256, uint256> > llmq::CSigSharesManager::pendingSigns
private

Definition at line 374 of file quorums_signing_shares.h.

◆ recoveredSigsCounter

std::atomic<uint32_t> llmq::CSigSharesManager::recoveredSigsCounter {0}
private

Definition at line 380 of file quorums_signing_shares.h.

◆ rnd

FastRandomContext llmq::CSigSharesManager::rnd
private

Definition at line 377 of file quorums_signing_shares.h.

◆ SESSION_NEW_SHARES_TIMEOUT

const int64_t llmq::CSigSharesManager::SESSION_NEW_SHARES_TIMEOUT = 60
staticprivate

Definition at line 344 of file quorums_signing_shares.h.

◆ SIG_SHARE_REQUEST_TIMEOUT

const int64_t llmq::CSigSharesManager::SIG_SHARE_REQUEST_TIMEOUT = 5
staticprivate

Definition at line 345 of file quorums_signing_shares.h.

◆ signedSessions

std::unordered_map<uint256, CSignedSession, StaticSaltedHasher> llmq::CSigSharesManager::signedSessions
private

Definition at line 365 of file quorums_signing_shares.h.

◆ sigShares

SigShareMap<CSigShare> llmq::CSigSharesManager::sigShares
private

Definition at line 364 of file quorums_signing_shares.h.

◆ sigSharesRequested

SigShareMap<std::pair<NodeId, int64_t> > llmq::CSigSharesManager::sigSharesRequested
private

Definition at line 371 of file quorums_signing_shares.h.

◆ sigSharesToAnnounce

SigShareMap<bool> llmq::CSigSharesManager::sigSharesToAnnounce
private

Definition at line 372 of file quorums_signing_shares.h.

◆ timeSeenForSessions

std::unordered_map<uint256, int64_t, StaticSaltedHasher> llmq::CSigSharesManager::timeSeenForSessions
private

Definition at line 368 of file quorums_signing_shares.h.

◆ workThread

std::thread llmq::CSigSharesManager::workThread
private

Definition at line 361 of file quorums_signing_shares.h.


The documentation for this class was generated from the following files: