Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <quorums_chainlocks.h>
Public Member Functions | |
CChainLocksHandler () | |
~CChainLocksHandler () | |
void | Start () |
void | Stop () |
bool | AlreadyHave (const CInv &inv) |
bool | GetChainLockByHash (const uint256 &hash, CChainLockSig &ret) |
CChainLockSig | GetBestChainLock () |
void | ProcessMessage (CNode *pfrom, const std::string &strCommand, CDataStream &vRecv, CConnman &connman) |
void | ProcessNewChainLock (NodeId from, const CChainLockSig &clsig, const uint256 &hash) |
void | AcceptedBlockHeader (const CBlockIndex *pindexNew) |
void | UpdatedBlockTip (const CBlockIndex *pindexNew) |
void | TransactionAddedToMempool (const CTransactionRef &tx, int64_t nAcceptTime) |
void | BlockConnected (const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindex, const std::vector< CTransactionRef > &vtxConflicted) |
void | BlockDisconnected (const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexDisconnected) |
void | CheckActiveState () |
void | TrySignChainTip () |
void | EnforceBestChainLock () |
virtual void | HandleNewRecoveredSig (const CRecoveredSig &recoveredSig) |
bool | HasChainLock (int nHeight, const uint256 &blockHash) |
bool | HasConflictingChainLock (int nHeight, const uint256 &blockHash) |
bool | IsTxSafeForMining (const uint256 &txid) |
Public Member Functions inherited from llmq::CRecoveredSigsListener | |
virtual | ~CRecoveredSigsListener () |
Private Types | |
typedef std::unordered_map< uint256, std::shared_ptr< std::unordered_set< uint256, StaticSaltedHasher > > > | BlockTxs |
Private Member Functions | |
bool | InternalHasChainLock (int nHeight, const uint256 &blockHash) |
bool | InternalHasConflictingChainLock (int nHeight, const uint256 &blockHash) |
void | DoInvalidateBlock (const CBlockIndex *pindex) |
BlockTxs::mapped_type | GetBlockTxs (const uint256 &blockHash) |
void | Cleanup () |
Private Attributes | |
CScheduler * | scheduler |
boost::thread * | scheduler_thread |
CCriticalSection | cs |
bool | tryLockChainTipScheduled {false} |
bool | isSporkActive {false} |
bool | isEnforced {false} |
uint256 | bestChainLockHash |
CChainLockSig | bestChainLock |
CChainLockSig | bestChainLockWithKnownBlock |
const CBlockIndex * | bestChainLockBlockIndex {nullptr} |
const CBlockIndex * | lastNotifyChainLockBlockIndex {nullptr} |
int32_t | lastSignedHeight {-1} |
uint256 | lastSignedRequestId |
uint256 | lastSignedMsgHash |
BlockTxs | blockTxs |
std::unordered_map< uint256, int64_t > | txFirstSeenTime |
std::map< uint256, int64_t > | seenChainLocks |
int64_t | lastCleanupTime {0} |
Static Private Attributes | |
static const int64_t | CLEANUP_INTERVAL = 1000 * 30 |
static const int64_t | CLEANUP_SEEN_TIMEOUT = 24 * 60 * 60 * 1000 |
static const int64_t | WAIT_FOR_ISLOCK_TIMEOUT = 10 * 60 |
Detailed Description
Definition at line 47 of file quorums_chainlocks.h.
Member Typedef Documentation
◆ BlockTxs
|
private |
Definition at line 75 of file quorums_chainlocks.h.
Constructor & Destructor Documentation
◆ CChainLocksHandler()
|
explicit |
Definition at line 36 of file quorums_chainlocks.cpp.
References scheduler, scheduler_thread, and CScheduler::serviceQueue().
◆ ~CChainLocksHandler()
llmq::CChainLocksHandler::~CChainLocksHandler | ( | ) |
Definition at line 43 of file quorums_chainlocks.cpp.
References scheduler, and scheduler_thread.
Member Function Documentation
◆ AcceptedBlockHeader()
void llmq::CChainLocksHandler::AcceptedBlockHeader | ( | const CBlockIndex * | pindexNew | ) |
Definition at line 184 of file quorums_chainlocks.cpp.
References bestChainLock, bestChainLockBlockIndex, bestChainLockWithKnownBlock, llmq::CChainLockSig::blockHash, cs, cs_main, CBlockIndex::GetBlockHash(), LOCK2, LogPrintf, llmq::CChainLockSig::nHeight, CBlockIndex::nHeight, llmq::CChainLockSig::ToString(), and base_blob< BITS >::ToString().
Referenced by CDSNotificationInterface::AcceptedBlockHeader().
◆ AlreadyHave()
bool llmq::CChainLocksHandler::AlreadyHave | ( | const CInv & | inv | ) |
Definition at line 68 of file quorums_chainlocks.cpp.
References cs, CInv::hash, LOCK, and seenChainLocks.
Referenced by AlreadyHave().
◆ BlockConnected()
void llmq::CChainLocksHandler::BlockConnected | ( | const std::shared_ptr< const CBlock > & | pblock, |
const CBlockIndex * | pindex, | ||
const std::vector< CTransactionRef > & | vtxConflicted | ||
) |
Definition at line 374 of file quorums_chainlocks.cpp.
References blockTxs, cs, GetAdjustedTime(), CBlockIndex::GetBlockHash(), CMasternodeSync::IsBlockchainSynced(), LOCK, masternodeSync, and txFirstSeenTime.
Referenced by CDSNotificationInterface::BlockConnected().
◆ BlockDisconnected()
void llmq::CChainLocksHandler::BlockDisconnected | ( | const std::shared_ptr< const CBlock > & | pblock, |
const CBlockIndex * | pindexDisconnected | ||
) |
Definition at line 407 of file quorums_chainlocks.cpp.
References blockTxs, cs, CBlockIndex::GetBlockHash(), and LOCK.
Referenced by CDSNotificationInterface::BlockDisconnected().
◆ CheckActiveState()
void llmq::CChainLocksHandler::CheckActiveState | ( | ) |
Definition at line 225 of file quorums_chainlocks.cpp.
References bestChainLock, bestChainLockBlockIndex, bestChainLockHash, bestChainLockWithKnownBlock, chainActive, cs, cs_main, Consensus::DEPLOYMENT_DIP0008, CChainParams::GetConsensus(), isEnforced, isSporkActive, CSporkManager::IsSporkActive(), lastNotifyChainLockBlockIndex, LOCK, Params(), CBlockIndex::pprev, SPORK_19_CHAINLOCKS_ENABLED, sporkManager, THRESHOLD_ACTIVE, CChain::Tip(), versionbitscache, and VersionBitsState().
Referenced by ProcessNewChainLock(), Start(), and UpdatedBlockTip().
◆ Cleanup()
|
private |
Definition at line 669 of file quorums_chainlocks.cpp.
References blockTxs, chainActive, CLEANUP_INTERVAL, CLEANUP_SEEN_TIMEOUT, cs, CTxMemPool::cs, cs_main, CBlockIndex::GetAncestor(), GetTimeMillis(), GetTransaction(), CChain::Height(), InternalHasChainLock(), InternalHasConflictingChainLock(), CMasternodeSync::IsBlockchainSynced(), base_blob< BITS >::IsNull(), lastCleanupTime, LOCK, LOCK2, mapBlockIndex, masternodeSync, mempool, Params(), seenChainLocks, CChain::Tip(), and txFirstSeenTime.
Referenced by TrySignChainTip().
◆ DoInvalidateBlock()
|
private |
Definition at line 591 of file quorums_chainlocks.cpp.
References cs_main, FormatStateMessage(), CBlockIndex::GetBlockHash(), InvalidateBlock(), LOCK, LogPrintf, mapBlockIndex, and Params().
Referenced by EnforceBestChainLock().
◆ EnforceBestChainLock()
void llmq::CChainLocksHandler::EnforceBestChainLock | ( | ) |
Definition at line 491 of file quorums_chainlocks.cpp.
References ActivateBestChain(), bestChainLockBlockIndex, bestChainLockWithKnownBlock, chainActive, CChain::Contains(), cs, cs_main, DoInvalidateBlock(), FormatStateMessage(), CBlockIndex::GetAncestor(), CBlockIndex::GetBlockHash(), GetMainSignals(), isEnforced, CBlockIndex::IsValid(), lastNotifyChainLockBlockIndex, LOCK, LogPrintf, mapBlockIndex, mapPrevBlockIndex, CBlockIndex::nHeight, CMainSignals::NotifyChainLock(), Params(), CBlockIndex::pprev, ResetBlockFailureFlags(), CChain::Tip(), and llmq::CChainLockSig::ToString().
Referenced by ProcessNewChainLock(), Start(), and UpdatedBlockTip().
◆ GetBestChainLock()
CChainLockSig llmq::CChainLocksHandler::GetBestChainLock | ( | ) |
Definition at line 87 of file quorums_chainlocks.cpp.
References bestChainLock, cs, and LOCK.
Referenced by getbestchainlock().
◆ GetBlockTxs()
|
private |
Definition at line 413 of file quorums_chainlocks.cpp.
References AssertLockNotHeld, blockTxs, BCLog::CHAINLOCKS, cs, cs_main, LOCK, LogPrint, mapBlockIndex, CBlockHeader::nTime, Params(), ReadBlockFromDisk(), base_blob< BITS >::ToString(), txFirstSeenTime, and CBlock::vtx.
Referenced by TrySignChainTip().
◆ GetChainLockByHash()
bool llmq::CChainLocksHandler::GetChainLockByHash | ( | const uint256 & | hash, |
llmq::CChainLockSig & | ret | ||
) |
Definition at line 74 of file quorums_chainlocks.cpp.
References bestChainLock, bestChainLockHash, cs, and LOCK.
◆ HandleNewRecoveredSig()
|
virtual |
Implements llmq::CRecoveredSigsListener.
Definition at line 564 of file quorums_chainlocks.cpp.
References bestChainLock, llmq::CChainLockSig::blockHash, cs, CBLSLazyWrapper< BLSObject >::Get(), llmq::CRecoveredSig::id, isSporkActive, lastSignedHeight, lastSignedMsgHash, lastSignedRequestId, LOCK, llmq::CRecoveredSig::msgHash, llmq::CChainLockSig::nHeight, ProcessNewChainLock(), SerializeHash(), llmq::CRecoveredSig::sig, and llmq::CChainLockSig::sig.
◆ HasChainLock()
bool llmq::CChainLocksHandler::HasChainLock | ( | int | nHeight, |
const uint256 & | blockHash | ||
) |
Definition at line 608 of file quorums_chainlocks.cpp.
References cs, InternalHasChainLock(), and LOCK.
Referenced by blockToJSON(), CMerkleTx::IsChainLocked(), CPrivateSendBroadcastTx::IsExpired(), llmq::CInstantSendManager::ProcessNewTransaction(), llmq::CInstantSendManager::ResolveBlockConflicts(), TrySignChainTip(), TxToJSON(), and WalletTxToJSON().
◆ HasConflictingChainLock()
bool llmq::CChainLocksHandler::HasConflictingChainLock | ( | int | nHeight, |
const uint256 & | blockHash | ||
) |
Definition at line 638 of file quorums_chainlocks.cpp.
References cs, InternalHasConflictingChainLock(), and LOCK.
Referenced by CChainState::ConnectBlock().
◆ InternalHasChainLock()
|
private |
Definition at line 614 of file quorums_chainlocks.cpp.
References AssertLockHeld(), bestChainLockBlockIndex, cs, CBlockIndex::GetAncestor(), CBlockIndex::GetBlockHash(), isEnforced, and CBlockIndex::nHeight.
Referenced by Cleanup(), and HasChainLock().
◆ InternalHasConflictingChainLock()
|
private |
Definition at line 644 of file quorums_chainlocks.cpp.
References AssertLockHeld(), bestChainLockBlockIndex, cs, CBlockIndex::GetAncestor(), CBlockIndex::GetBlockHash(), isEnforced, and CBlockIndex::nHeight.
Referenced by Cleanup(), HasConflictingChainLock(), ProcessNewChainLock(), and TrySignChainTip().
◆ IsTxSafeForMining()
bool llmq::CChainLocksHandler::IsTxSafeForMining | ( | const uint256 & | txid | ) |
Definition at line 462 of file quorums_chainlocks.cpp.
References cs, GetAdjustedTime(), llmq::IsInstantSendEnabled(), isSporkActive, CSporkManager::IsSporkActive(), LOCK, SPORK_3_INSTANTSEND_BLOCK_FILTERING, sporkManager, and txFirstSeenTime.
◆ ProcessMessage()
void llmq::CChainLocksHandler::ProcessMessage | ( | CNode * | pfrom, |
const std::string & | strCommand, | ||
CDataStream & | vRecv, | ||
CConnman & | connman | ||
) |
Definition at line 93 of file quorums_chainlocks.cpp.
References NetMsgType::CLSIG, CNode::GetId(), CSporkManager::IsSporkActive(), ProcessNewChainLock(), SerializeHash(), SPORK_19_CHAINLOCKS_ENABLED, and sporkManager.
Referenced by ProcessMessage().
◆ ProcessNewChainLock()
void llmq::CChainLocksHandler::ProcessNewChainLock | ( | NodeId | from, |
const CChainLockSig & | clsig, | ||
const uint256 & | hash | ||
) |
Definition at line 109 of file quorums_chainlocks.cpp.
References bestChainLock, bestChainLockBlockIndex, bestChainLockHash, bestChainLockWithKnownBlock, llmq::CChainLockSig::blockHash, BCLog::CHAINLOCKS, CheckActiveState(), llmq::CLSIG_REQUESTID_PREFIX, cs, cs_main, EnforceBestChainLock(), EraseObjectRequest(), g_connman, GetTimeMillis(), InternalHasConflictingChainLock(), llmq::CChainLockSig::IsNull(), LLMQS_PROTO_VERSION, LOCK, LOCK2, LogPrint, LogPrintf, mapBlockIndex, Misbehaving(), MSG_CLSIG, llmq::CChainLockSig::nHeight, Params(), llmq::quorumSigningManager, CScheduler::scheduleFromNow(), scheduler, seenChainLocks, SerializeHash(), llmq::CChainLockSig::sig, llmq::CChainLockSig::ToString(), and llmq::CSigningManager::VerifyRecoveredSig().
Referenced by HandleNewRecoveredSig(), and ProcessMessage().
◆ Start()
void llmq::CChainLocksHandler::Start | ( | ) |
Definition at line 51 of file quorums_chainlocks.cpp.
References CheckActiveState(), EnforceBestChainLock(), llmq::quorumSigningManager, llmq::CSigningManager::RegisterRecoveredSigsListener(), CScheduler::scheduleEvery(), scheduler, and TrySignChainTip().
Referenced by llmq::StartLLMQSystem().
◆ Stop()
void llmq::CChainLocksHandler::Stop | ( | ) |
Definition at line 62 of file quorums_chainlocks.cpp.
References llmq::quorumSigningManager, scheduler, CScheduler::stop(), and llmq::CSigningManager::UnregisterRecoveredSigsListener().
Referenced by llmq::StopLLMQSystem().
◆ TransactionAddedToMempool()
void llmq::CChainLocksHandler::TransactionAddedToMempool | ( | const CTransactionRef & | tx, |
int64_t | nAcceptTime | ||
) |
Definition at line 364 of file quorums_chainlocks.cpp.
References cs, LOCK, and txFirstSeenTime.
Referenced by CDSNotificationInterface::TransactionAddedToMempool().
◆ TrySignChainTip()
void llmq::CChainLocksHandler::TrySignChainTip | ( | ) |
Definition at line 248 of file quorums_chainlocks.cpp.
References llmq::CSigningManager::AsyncSignIfMember(), bestChainLock, chainActive, BCLog::CHAINLOCKS, Cleanup(), llmq::CLSIG_REQUESTID_PREFIX, cs, cs_main, fMasternodeMode, GetAdjustedTime(), CBlockIndex::GetBlockHash(), GetBlockTxs(), HasChainLock(), InternalHasConflictingChainLock(), CMasternodeSync::IsBlockchainSynced(), llmq::IsInstantSendEnabled(), isSporkActive, CSporkManager::IsSporkActive(), lastSignedHeight, lastSignedMsgHash, lastSignedRequestId, LOCK, LogPrint, masternodeSync, llmq::CChainLockSig::nHeight, CBlockIndex::nHeight, Params(), CBlockIndex::pprev, llmq::quorumSigningManager, SerializeHash(), SPORK_3_INSTANTSEND_BLOCK_FILTERING, sporkManager, CChain::Tip(), base_blob< BITS >::ToString(), and txFirstSeenTime.
Referenced by Start(), and UpdatedBlockTip().
◆ UpdatedBlockTip()
void llmq::CChainLocksHandler::UpdatedBlockTip | ( | const CBlockIndex * | pindexNew | ) |
Definition at line 206 of file quorums_chainlocks.cpp.
References CheckActiveState(), cs, EnforceBestChainLock(), LOCK, CScheduler::scheduleFromNow(), scheduler, tryLockChainTipScheduled, and TrySignChainTip().
Referenced by CDSNotificationInterface::UpdatedBlockTip().
Member Data Documentation
◆ bestChainLock
|
private |
Definition at line 64 of file quorums_chainlocks.h.
Referenced by AcceptedBlockHeader(), CheckActiveState(), GetBestChainLock(), GetChainLockByHash(), HandleNewRecoveredSig(), ProcessNewChainLock(), and TrySignChainTip().
◆ bestChainLockBlockIndex
|
private |
Definition at line 67 of file quorums_chainlocks.h.
Referenced by AcceptedBlockHeader(), CheckActiveState(), EnforceBestChainLock(), InternalHasChainLock(), InternalHasConflictingChainLock(), and ProcessNewChainLock().
◆ bestChainLockHash
|
private |
Definition at line 63 of file quorums_chainlocks.h.
Referenced by CheckActiveState(), GetChainLockByHash(), and ProcessNewChainLock().
◆ bestChainLockWithKnownBlock
|
private |
Definition at line 66 of file quorums_chainlocks.h.
Referenced by AcceptedBlockHeader(), CheckActiveState(), EnforceBestChainLock(), and ProcessNewChainLock().
◆ blockTxs
|
private |
Definition at line 76 of file quorums_chainlocks.h.
Referenced by BlockConnected(), BlockDisconnected(), Cleanup(), and GetBlockTxs().
◆ CLEANUP_INTERVAL
|
staticprivate |
Definition at line 49 of file quorums_chainlocks.h.
Referenced by Cleanup().
◆ CLEANUP_SEEN_TIMEOUT
|
staticprivate |
Definition at line 50 of file quorums_chainlocks.h.
Referenced by Cleanup().
◆ cs
|
private |
Definition at line 58 of file quorums_chainlocks.h.
Referenced by AcceptedBlockHeader(), AlreadyHave(), BlockConnected(), BlockDisconnected(), CheckActiveState(), Cleanup(), EnforceBestChainLock(), GetBestChainLock(), GetBlockTxs(), GetChainLockByHash(), HandleNewRecoveredSig(), HasChainLock(), HasConflictingChainLock(), InternalHasChainLock(), InternalHasConflictingChainLock(), IsTxSafeForMining(), ProcessNewChainLock(), TransactionAddedToMempool(), TrySignChainTip(), and UpdatedBlockTip().
◆ isEnforced
|
private |
Definition at line 61 of file quorums_chainlocks.h.
Referenced by CheckActiveState(), EnforceBestChainLock(), InternalHasChainLock(), and InternalHasConflictingChainLock().
◆ isSporkActive
|
private |
Definition at line 60 of file quorums_chainlocks.h.
Referenced by CheckActiveState(), HandleNewRecoveredSig(), IsTxSafeForMining(), and TrySignChainTip().
◆ lastCleanupTime
|
private |
Definition at line 81 of file quorums_chainlocks.h.
Referenced by Cleanup().
◆ lastNotifyChainLockBlockIndex
|
private |
Definition at line 68 of file quorums_chainlocks.h.
Referenced by CheckActiveState(), and EnforceBestChainLock().
◆ lastSignedHeight
|
private |
Definition at line 70 of file quorums_chainlocks.h.
Referenced by HandleNewRecoveredSig(), and TrySignChainTip().
◆ lastSignedMsgHash
|
private |
Definition at line 72 of file quorums_chainlocks.h.
Referenced by HandleNewRecoveredSig(), and TrySignChainTip().
◆ lastSignedRequestId
|
private |
Definition at line 71 of file quorums_chainlocks.h.
Referenced by HandleNewRecoveredSig(), and TrySignChainTip().
◆ scheduler
|
private |
Definition at line 56 of file quorums_chainlocks.h.
Referenced by CChainLocksHandler(), ProcessNewChainLock(), Start(), Stop(), UpdatedBlockTip(), and ~CChainLocksHandler().
◆ scheduler_thread
|
private |
Definition at line 57 of file quorums_chainlocks.h.
Referenced by CChainLocksHandler(), and ~CChainLocksHandler().
◆ seenChainLocks
|
private |
Definition at line 79 of file quorums_chainlocks.h.
Referenced by AlreadyHave(), Cleanup(), and ProcessNewChainLock().
◆ tryLockChainTipScheduled
|
private |
Definition at line 59 of file quorums_chainlocks.h.
Referenced by UpdatedBlockTip().
◆ txFirstSeenTime
|
private |
Definition at line 77 of file quorums_chainlocks.h.
Referenced by BlockConnected(), Cleanup(), GetBlockTxs(), IsTxSafeForMining(), TransactionAddedToMempool(), and TrySignChainTip().
◆ WAIT_FOR_ISLOCK_TIMEOUT
|
staticprivate |
Definition at line 53 of file quorums_chainlocks.h.
The documentation for this class was generated from the following files:
- src/llmq/quorums_chainlocks.h
- src/llmq/quorums_chainlocks.cpp