Skip to content

Commit

Permalink
refactor: remove llmq::CQuorumBlockProcessor global, move to `LLMQC…
Browse files Browse the repository at this point in the history
…ontext`

We used to store an alias to the `CQuorumBlockProcessor` instance present
in the global state in `LLMQContext` but handled construction and
destruction of the instance in `LLMQContext`. As direct global usage no
longer exists, we can fully subsume it into `LLMQContext`.
  • Loading branch information
kwvg committed May 29, 2024
1 parent 1d3afe7 commit 1efd219
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 15 deletions.
3 changes: 0 additions & 3 deletions src/llmq/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ static void PreComputeQuorumMembers(CDeterministicMNManager& dmnman, const CBloc

namespace llmq
{

std::unique_ptr<CQuorumBlockProcessor> quorumBlockProcessor;

static const std::string DB_MINED_COMMITMENT = "q_mc";
static const std::string DB_MINED_COMMITMENT_BY_INVERSED_HEIGHT = "q_mcih";
static const std::string DB_MINED_COMMITMENT_BY_INVERSED_HEIGHT_Q_INDEXED = "q_mcihi";
Expand Down
3 changes: 0 additions & 3 deletions src/llmq/blockprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ class CQuorumBlockProcessor
size_t GetNumCommitmentsRequired(const Consensus::LLMQParams& llmqParams, int nHeight) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
static uint256 GetQuorumBlockHash(const Consensus::LLMQParams& llmqParams, int nHeight, int quorumIndex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
};

extern std::unique_ptr<CQuorumBlockProcessor> quorumBlockProcessor;

} // namespace llmq

#endif // BITCOIN_LLMQ_BLOCKPROCESSOR_H
9 changes: 1 addition & 8 deletions src/llmq/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis
is_masternode{mn_activeman != nullptr},
bls_worker{std::make_shared<CBLSWorker>()},
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
quorum_block_processor{[&]() -> llmq::CQuorumBlockProcessor* const {
assert(llmq::quorumBlockProcessor == nullptr);
llmq::quorumBlockProcessor = std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, dmnman, evo_db, peerman);
return llmq::quorumBlockProcessor.get();
}()},
quorum_block_processor{std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, dmnman, evo_db, peerman)},
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, dmnman, *dkg_debugman, mn_metaman, *quorum_block_processor, mn_activeman, sporkman, peerman, unit_tests, wipe)},
qman{[&]() -> llmq::CQuorumManager* const {
assert(llmq::quorumManager == nullptr);
Expand Down Expand Up @@ -59,7 +55,6 @@ LLMQContext::~LLMQContext() {
llmq::quorumInstantSendManager.reset();
llmq::chainLocksHandler.reset();
llmq::quorumManager.reset();
llmq::quorumBlockProcessor.reset();
}

void LLMQContext::Interrupt() {
Expand All @@ -71,7 +66,6 @@ void LLMQContext::Interrupt() {
}

void LLMQContext::Start() {
assert(quorum_block_processor == llmq::quorumBlockProcessor.get());
assert(qman == llmq::quorumManager.get());
assert(clhandler == llmq::chainLocksHandler.get());
assert(isman == llmq::quorumInstantSendManager.get());
Expand All @@ -90,7 +84,6 @@ void LLMQContext::Start() {
}

void LLMQContext::Stop() {
assert(quorum_block_processor == llmq::quorumBlockProcessor.get());
assert(qman == llmq::quorumManager.get());
assert(clhandler == llmq::chainLocksHandler.get());
assert(isman == llmq::quorumInstantSendManager.get());
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct LLMQContext {
*/
const std::shared_ptr<CBLSWorker> bls_worker;
const std::unique_ptr<llmq::CDKGDebugManager> dkg_debugman;
llmq::CQuorumBlockProcessor* const quorum_block_processor;
const std::unique_ptr<llmq::CQuorumBlockProcessor> quorum_block_processor;
const std::unique_ptr<llmq::CDKGSessionManager> qdkgsman;
llmq::CQuorumManager* const qman;
const std::unique_ptr<llmq::CSigningManager> sigman;
Expand Down

0 comments on commit 1efd219

Please sign in to comment.