Skip to content

Commit 38bfafa

Browse files
committed
refactor: rename llmq::CChainLocksHandler to chainlock::ChainlockHandler
1 parent a894ff7 commit 38bfafa

15 files changed

Lines changed: 71 additions & 68 deletions

File tree

src/active/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman, CConnman& connman,
2727
CDeterministicMNManager& dmnman, CGovernanceManager& govman,
2828
CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, CSporkManager& sporkman, const chainlock::Chainlocks& chainlocks,
29-
CTxMemPool& mempool, llmq::CChainLocksHandler& clhandler, llmq::CInstantSendManager& isman,
29+
CTxMemPool& mempool, chainlock::ChainlockHandler& clhandler, llmq::CInstantSendManager& isman,
3030
llmq::CQuorumBlockProcessor& qblockman, llmq::CQuorumManager& qman,
3131
llmq::CQuorumSnapshotManager& qsnapman, llmq::CSigningManager& sigman,
3232
PeerManager& peerman, const CMasternodeSync& mn_sync, const CBLSSecretKey& operator_sk,

src/active/context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class GovernanceSigner;
3030
class PeerManager;
3131
namespace chainlock {
3232
class Chainlocks;
33+
class ChainlockHandler;
3334
class ChainLockSigner;
3435
} // namespace chainlock
3536
namespace instantsend {
3637
class InstantSendSigner;
3738
} // namespace instantsend
3839
namespace llmq {
39-
class CChainLocksHandler;
4040
class CDKGDebugManager;
4141
class CDKGSessionManager;
4242
class CEHFSignalsHandler;
@@ -64,7 +64,7 @@ struct ActiveContext final : public CValidationInterface {
6464
explicit ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman, CConnman& connman,
6565
CDeterministicMNManager& dmnman, CGovernanceManager& govman, CMasternodeMetaMan& mn_metaman,
6666
CMNHFManager& mnhfman, CSporkManager& sporkman, const chainlock::Chainlocks& chainlocks, CTxMemPool& mempool,
67-
llmq::CChainLocksHandler& clhandler, llmq::CInstantSendManager& isman,
67+
chainlock::ChainlockHandler& clhandler, llmq::CInstantSendManager& isman,
6868
llmq::CQuorumBlockProcessor& qblockman, llmq::CQuorumManager& qman,
6969
llmq::CQuorumSnapshotManager& qsnapman, llmq::CSigningManager& sigman, PeerManager& peerman,
7070
const CMasternodeSync& mn_sync, const CBLSSecretKey& operator_sk,

src/chainlock/chainlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ bool Chainlocks::UpdateBestChainlock(const uint256& hash, const chainlock::Chain
107107
if (pindex) {
108108
if (pindex->nHeight != clsig.getHeight()) {
109109
// Should not happen, same as the conflict check from above.
110-
LogPrintf("CChainLocksHandler::%s -- height of CLSIG (%s) does not match the specified block's height (%d)\n",
110+
LogPrintf("Chainlocks::%s -- height of CLSIG (%s) does not match the specified block's height (%d)\n",
111111
__func__, clsig.ToString(), pindex->nHeight);
112112
// Note: not relaying clsig here
113113
return false;

src/chainlock/handler.cpp

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMe
2929

3030
using node::GetTransaction;
3131

32-
namespace llmq {
3332
namespace {
3433
static constexpr auto CLEANUP_SEEN_TIMEOUT{24h};
3534
//! How long to wait for islocks until we consider a block with non-islocked TXs to be safe to sign
3635
static constexpr auto WAIT_FOR_ISLOCK_TIMEOUT{10min};
3736
} // anonymous namespace
3837

39-
CChainLocksHandler::CChainLocksHandler(chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
38+
namespace chainlock {
39+
ChainlockHandler::ChainlockHandler(chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
4040
CTxMemPool& _mempool, const CMasternodeSync& mn_sync) :
4141
m_chainlocks{chainlocks},
4242
m_chainman{chainman},
@@ -48,13 +48,13 @@ CChainLocksHandler::CChainLocksHandler(chainlock::Chainlocks& chainlocks, Chains
4848
{
4949
}
5050

51-
CChainLocksHandler::~CChainLocksHandler()
51+
ChainlockHandler::~ChainlockHandler()
5252
{
5353
scheduler->stop();
5454
scheduler_thread->join();
5555
}
5656

57-
void CChainLocksHandler::Start()
57+
void ChainlockHandler::Start()
5858
{
5959
scheduler->scheduleEvery(
6060
[&]() {
@@ -65,18 +65,18 @@ void CChainLocksHandler::Start()
6565
std::chrono::seconds{5});
6666
}
6767

68-
void CChainLocksHandler::Stop()
68+
void ChainlockHandler::Stop()
6969
{
7070
scheduler->stop();
7171
}
7272

73-
bool CChainLocksHandler::AlreadyHave(const CInv& inv) const
73+
bool ChainlockHandler::AlreadyHave(const CInv& inv) const
7474
{
7575
LOCK(cs);
7676
return seenChainLocks.count(inv.hash) != 0;
7777
}
7878

79-
void CChainLocksHandler::UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int64_t& time)
79+
void ChainlockHandler::UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int64_t& time)
8080
{
8181
AssertLockNotHeld(cs);
8282
LOCK(cs);
@@ -85,7 +85,7 @@ void CChainLocksHandler::UpdateTxFirstSeenMap(const Uint256HashSet& tx, const in
8585
}
8686
}
8787

88-
MessageProcessingResult CChainLocksHandler::ProcessNewChainLock(const NodeId from, const chainlock::ChainLockSig& clsig, const llmq::CQuorumManager& qman,
88+
MessageProcessingResult ChainlockHandler::ProcessNewChainLock(const NodeId from, const chainlock::ChainLockSig& clsig, const llmq::CQuorumManager& qman,
8989
const uint256& hash)
9090
{
9191
CheckActiveState();
@@ -103,8 +103,8 @@ MessageProcessingResult CChainLocksHandler::ProcessNewChainLock(const NodeId fro
103103
}
104104
}
105105

106-
if (const auto ret = chainlock::VerifyChainLock(Params().GetConsensus(), m_chainman.ActiveChain(), qman, clsig); ret != VerifyRecSigStatus::Valid) {
107-
LogPrint(BCLog::CHAINLOCKS, "CChainLocksHandler::%s -- invalid CLSIG (%s), status=%d peer=%d\n", __func__,
106+
if (const auto ret = chainlock::VerifyChainLock(Params().GetConsensus(), m_chainman.ActiveChain(), qman, clsig); ret != llmq::VerifyRecSigStatus::Valid) {
107+
LogPrint(BCLog::CHAINLOCKS, "ChainlockHandler::%s -- invalid CLSIG (%s), status=%d peer=%d\n", __func__,
108108
clsig.ToString(), ToUnderlying(ret), from);
109109
if (from != -1) {
110110
return MisbehavingError{10};
@@ -124,14 +124,14 @@ MessageProcessingResult CChainLocksHandler::ProcessNewChainLock(const NodeId fro
124124
},
125125
std::chrono::seconds{0});
126126

127-
LogPrint(BCLog::CHAINLOCKS, "CChainLocksHandler::%s -- processed new CLSIG (%s), peer=%d\n", __func__,
127+
LogPrint(BCLog::CHAINLOCKS, "ChainlockHandler::%s -- processed new CLSIG (%s), peer=%d\n", __func__,
128128
clsig.ToString(), from);
129129
}
130130
const CInv clsig_inv(MSG_CLSIG, hash);
131131
return clsig_inv;
132132
}
133133

134-
void CChainLocksHandler::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
134+
void ChainlockHandler::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
135135
{
136136
if (pindexNew == pindexFork) // blocks were disconnected without any new ones
137137
return;
@@ -155,7 +155,7 @@ void CChainLocksHandler::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBl
155155
}
156156
}
157157

158-
void CChainLocksHandler::CheckActiveState()
158+
void ChainlockHandler::CheckActiveState()
159159
{
160160
bool oldIsEnabled = isEnabled;
161161
isEnabled = m_chainlocks.IsEnabled();
@@ -170,7 +170,7 @@ void CChainLocksHandler::CheckActiveState()
170170
}
171171
}
172172

173-
void CChainLocksHandler::TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime, uint64_t)
173+
void ChainlockHandler::TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime, uint64_t)
174174
{
175175
if (tx->IsCoinBase() || tx->vin.empty()) {
176176
return;
@@ -180,12 +180,12 @@ void CChainLocksHandler::TransactionAddedToMempool(const CTransactionRef& tx, in
180180
txFirstSeenTime.emplace(tx->GetHash(), nAcceptTime);
181181
}
182182

183-
void CChainLocksHandler::AcceptedBlockHeader(const CBlockIndex* pindexNew)
183+
void ChainlockHandler::AcceptedBlockHeader(const CBlockIndex* pindexNew)
184184
{
185185
m_chainlocks.AcceptedBlockHeader(pindexNew);
186186
}
187187

188-
void CChainLocksHandler::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
188+
void ChainlockHandler::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
189189
{
190190
if (!m_mn_sync.IsBlockchainSynced()) {
191191
return;
@@ -203,7 +203,7 @@ void CChainLocksHandler::BlockConnected(const std::shared_ptr<const CBlock>& pbl
203203
}
204204
}
205205

206-
bool CChainLocksHandler::IsTxSafeForMining(const uint256& txid) const
206+
bool ChainlockHandler::IsTxSafeForMining(const uint256& txid) const
207207
{
208208
auto tx_age{0s};
209209
{
@@ -219,7 +219,7 @@ bool CChainLocksHandler::IsTxSafeForMining(const uint256& txid) const
219219

220220
// WARNING: cs_main and cs should not be held!
221221
// This should also not be called from validation signals, as this might result in recursive calls
222-
void CChainLocksHandler::EnforceBestChainLock()
222+
void ChainlockHandler::EnforceBestChainLock()
223223
{
224224
if (!isEnabled) {
225225
return;
@@ -240,7 +240,7 @@ void CChainLocksHandler::EnforceBestChainLock()
240240
// Go backwards through the chain referenced by clsig until we find a block that is part of the main chain.
241241
// For each of these blocks, check if there are children that are NOT part of the chain referenced by clsig
242242
// and mark all of them as conflicting.
243-
LogPrint(BCLog::CHAINLOCKS, "CChainLocksHandler::%s -- enforcing block %s via CLSIG (%s)\n", __func__,
243+
LogPrint(BCLog::CHAINLOCKS, "ChainlockHandler::%s -- enforcing block %s via CLSIG (%s)\n", __func__,
244244
currentBestChainLockBlockIndex->GetBlockHash().ToString(), clsig.ToString());
245245
m_chainman.ActiveChainstate().EnforceBlock(dummy_state, currentBestChainLockBlockIndex);
246246

@@ -249,7 +249,7 @@ void CChainLocksHandler::EnforceBestChainLock()
249249
currentBestChainLockBlockIndex->nHeight)) !=
250250
currentBestChainLockBlockIndex) {
251251
if (!m_chainman.ActiveChainstate().ActivateBestChain(dummy_state)) {
252-
LogPrintf("CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, dummy_state.ToString());
252+
LogPrintf("ChainlockHandler::%s -- ActivateBestChain failed: %s\n", __func__, dummy_state.ToString());
253253
return;
254254
}
255255
LOCK(::cs_main);
@@ -270,7 +270,7 @@ void CChainLocksHandler::EnforceBestChainLock()
270270
::g_stats_client->gauge("chainlocks.blockHeight", clsig.getHeight(), 1.0f);
271271
}
272272

273-
void CChainLocksHandler::CleanupFromSigner(const std::vector<std::shared_ptr<Uint256HashSet>>& cleanup_txes)
273+
void ChainlockHandler::CleanupFromSigner(const std::vector<std::shared_ptr<Uint256HashSet>>& cleanup_txes)
274274
{
275275
LOCK(cs);
276276
for (const auto& tx : cleanup_txes) {
@@ -280,7 +280,7 @@ void CChainLocksHandler::CleanupFromSigner(const std::vector<std::shared_ptr<Uin
280280
}
281281
}
282282

283-
void CChainLocksHandler::Cleanup()
283+
void ChainlockHandler::Cleanup()
284284
{
285285
constexpr auto CLEANUP_INTERVAL{30s};
286286
if (!m_mn_sync.IsBlockchainSynced()) {
@@ -324,10 +324,7 @@ void CChainLocksHandler::Cleanup()
324324
}
325325
}
326326
}
327-
} // namespace llmq
328327

329-
namespace chainlock
330-
{
331328
llmq::VerifyRecSigStatus VerifyChainLock(const Consensus::Params& params, const CChain& chain, const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig)
332329
{
333330
const auto llmqType = params.llmqTypeChainLocks;

src/chainlock/handler.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ class CScheduler;
3131
class CTxMemPool;
3232
struct MessageProcessingResult;
3333

34-
namespace chainlock {
35-
class Chainlocks;
36-
struct ChainLockSig;
37-
} // namespace chainlock
3834
namespace Consensus {
3935
struct Params;
4036
} // namespace Consensus
@@ -43,8 +39,13 @@ namespace llmq
4339
{
4440
class CQuorumManager;
4541
enum class VerifyRecSigStatus : uint8_t;
42+
} // namespace llmq
4643

47-
class CChainLocksHandler final : public CValidationInterface
44+
namespace chainlock {
45+
class Chainlocks;
46+
struct ChainLockSig;
47+
48+
class ChainlockHandler final : public CValidationInterface
4849
{
4950
private:
5051
chainlock::Chainlocks& m_chainlocks;
@@ -67,12 +68,12 @@ class CChainLocksHandler final : public CValidationInterface
6768
CleanupThrottler<NodeClock> cleanupThrottler;
6869

6970
public:
70-
CChainLocksHandler() = delete;
71-
CChainLocksHandler(const CChainLocksHandler&) = delete;
72-
CChainLocksHandler& operator=(const CChainLocksHandler&) = delete;
73-
explicit CChainLocksHandler(chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
71+
ChainlockHandler() = delete;
72+
ChainlockHandler(const ChainlockHandler&) = delete;
73+
ChainlockHandler& operator=(const ChainlockHandler&) = delete;
74+
explicit ChainlockHandler(chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
7475
CTxMemPool& _mempool, const CMasternodeSync& mn_sync);
75-
~CChainLocksHandler();
76+
~ChainlockHandler();
7677

7778
void Start();
7879
void Stop();
@@ -111,10 +112,7 @@ class CChainLocksHandler final : public CValidationInterface
111112
void Cleanup()
112113
EXCLUSIVE_LOCKS_REQUIRED(!cs);
113114
};
114-
} // namespace llmq
115115

116-
namespace chainlock
117-
{
118116
llmq::VerifyRecSigStatus VerifyChainLock(const Consensus::Params& params, const CChain& chain, const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig);
119117
} // namespace chainlock
120118

src/chainlock/signing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using node::ReadBlockFromDisk;
2121

2222
namespace chainlock {
23-
ChainLockSigner::ChainLockSigner(CChainState& chainstate, const chainlock::Chainlocks& chainlocks, llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, const llmq::CQuorumManager& qman,
23+
ChainLockSigner::ChainLockSigner(CChainState& chainstate, const chainlock::Chainlocks& chainlocks, ChainlockHandler& clhandler, const llmq::CInstantSendManager& isman, const llmq::CQuorumManager& qman,
2424
llmq::CSigningManager& sigman, llmq::CSigSharesManager& shareman,
2525
const CMasternodeSync& mn_sync) :
2626
m_chainstate{chainstate},

src/chainlock/signing.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ class CScheduler;
1515
class CMasternodeSync;
1616
struct MessageProcessingResult;
1717
namespace llmq {
18-
class CChainLocksHandler;
1918
class CInstantSendManager;
2019
class CRecoveredSig;
2120
class CSigningManager;
2221
class CSigSharesManager;
2322
} // namespace llmq
2423

2524
namespace chainlock {
26-
class ChainLockSigner final : public llmq::CRecoveredSigsListener, public CValidationInterface
25+
class ChainlockHandler;
2726

27+
class ChainLockSigner final : public llmq::CRecoveredSigsListener, public CValidationInterface
2828
{
2929
private:
3030
CChainState& m_chainstate;
3131
const chainlock::Chainlocks& m_chainlocks;
32-
llmq::CChainLocksHandler& m_clhandler;
32+
ChainlockHandler& m_clhandler;
3333
const llmq::CInstantSendManager& m_isman;
3434
const llmq::CQuorumManager& m_qman;
3535
llmq::CSigningManager& m_sigman;
@@ -59,7 +59,7 @@ class ChainLockSigner final : public llmq::CRecoveredSigsListener, public CValid
5959
ChainLockSigner() = delete;
6060
ChainLockSigner(const ChainLockSigner&) = delete;
6161
ChainLockSigner& operator=(const ChainLockSigner&) = delete;
62-
explicit ChainLockSigner(CChainState& chainstate, const chainlock::Chainlocks& chainlocks, llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, const llmq::CQuorumManager& qman, llmq::CSigningManager& sigman,
62+
explicit ChainLockSigner(CChainState& chainstate, const chainlock::Chainlocks& chainlocks, ChainlockHandler& clhandler, const llmq::CInstantSendManager& isman, const llmq::CQuorumManager& qman, llmq::CSigningManager& sigman,
6363
llmq::CSigSharesManager& shareman, const CMasternodeSync& mn_sync);
6464
~ChainLockSigner();
6565

src/evo/chainhelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CChainstateHelper::CChainstateHelper(CCreditPoolManager& cpoolman, CDeterministi
2727

2828
CChainstateHelper::~CChainstateHelper() = default;
2929

30-
/** Passthrough functions to CChainLocksHandler */
30+
/** Passthrough functions to chainlock::Chainlocks */
3131
bool CChainstateHelper::HasConflictingChainLock(int nHeight, const uint256& blockHash) const
3232
{
3333
return m_chainlocks.HasConflictingChainLock(nHeight, blockHash);

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
21712171
assert(!node.dstxman);
21722172
node.dstxman = std::make_unique<CDSTXManager>(*node.chainlocks);
21732173

2174-
node.clhandler = std::make_unique<llmq::CChainLocksHandler>(*node.chainlocks, chainman, *node.mempool, *node.mn_sync);
2174+
node.clhandler = std::make_unique<chainlock::ChainlockHandler>(*node.chainlocks, chainman, *node.mempool, *node.mn_sync);
21752175
RegisterValidationInterface(node.clhandler.get());
21762176

21772177
assert(!node.peerman);

src/instantsend/instantsend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ void CInstantSendManager::ResolveBlockConflicts(const uint256& islockHash, const
604604
if (activateBestChain) {
605605
BlockValidationState state;
606606
if (!m_chainstate.ActivateBestChain(state)) {
607-
LogPrintf("CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, state.ToString());
607+
LogPrintf("CInstantSendManager::%s -- ActivateBestChain failed: %s\n", __func__, state.ToString());
608608
// This should not have happened and we are in a state were it's not safe to continue anymore
609609
assert(false);
610610
}

0 commit comments

Comments
 (0)