Skip to content

Commit

Permalink
more cleanups and tidy-up
Browse files Browse the repository at this point in the history
  • Loading branch information
knst committed Oct 5, 2023
1 parent 55332c1 commit eaf582c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 62 deletions.
64 changes: 8 additions & 56 deletions src/llmq/ehf_signals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <evo/specialtx.h>

#include <index/txindex.h> // g_txindex
//#include <scheduler.h>

#include <validation.h>
#include <txmempool.h>
Expand All @@ -20,8 +19,6 @@
namespace llmq {


//std::unique_ptr<CEHFSignalsHandler> ehfSignalsHandler;

CEHFSignalsHandler::CEHFSignalsHandler(CChainState& chainstate, CConnman& connman,
CSigningManager& sigman, CSigSharesManager& shareman,
CQuorumManager& qman, CTxMemPool& mempool,
Expand All @@ -33,10 +30,6 @@ CEHFSignalsHandler::CEHFSignalsHandler(CChainState& chainstate, CConnman& connma
qman(qman),
mempool(mempool),
mnhfManager(mnhfManager)
/*,
scheduler(std::make_unique<CScheduler>()),
scheduler_thread(std::make_unique<std::thread>(std::thread(util::TraceThread, "cl-schdlr", [&] { scheduler->serviceQueue(); })))
*/
{
sigman.RegisterRecoveredSigsListener(this);
}
Expand All @@ -51,47 +44,22 @@ CEHFSignalsHandler::~CEHFSignalsHandler()
*/
}

void CEHFSignalsHandler::Start()
{
/* scheduler->scheduleEvery([&]() {
CheckActiveState();
EnforceBestChainLock();
// regularly retry signing the current chaintip as it might have failed before due to missing islocks
TrySignChainTip();
}, std::chrono::seconds{5});
*/
}

void CEHFSignalsHandler::Stop()
{
// scheduler->stop();
}

void CEHFSignalsHandler::UpdatedBlockTip(const CBlockIndex* const pindexNew)
{
/*
scheduler->scheduleFromNow([&]() {
CheckActiveState();
EnforceBestChainLock();
TrySignChainTip();
tryLockChainTipScheduled = false;
}, std::chrono::seconds{0});
*/
LogPrintf("knst bits: %d %d %d\n", Params().GetConsensus().vDeployments[Consensus::DEPLOYMENT_MN_RR].bit,
Params().GetConsensus().vDeployments[Consensus::DEPLOYMENT_V20].bit,
Params().GetConsensus().vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit);
if (llmq::utils::IsV20Active(pindexNew)) {
trySignEHFSignal(Params().GetConsensus().vDeployments[Consensus::DEPLOYMENT_MN_RR].bit, pindexNew);
if (!fMasternodeMode) {
return;
}

if (!llmq::utils::IsV20Active(pindexNew)) {
return;
}

trySignEHFSignal(Params().GetConsensus().vDeployments[Consensus::DEPLOYMENT_MN_RR].bit, pindexNew);
}

void CEHFSignalsHandler::trySignEHFSignal(int bit, const CBlockIndex* const pindex)
{
LogPrintf("knst trySign ehf: %d at height=%d\n", bit, pindex->nHeight);
if (!fMasternodeMode) {
LogPrintf("knst try sign - not masternode\n");
return;
}

/*
if (!m_mn_sync.IsBlockchainSynced()) {
Expand All @@ -118,21 +86,6 @@ void CEHFSignalsHandler::trySignEHFSignal(int bit, const CBlockIndex* const pind
LogPrintf("knst quorum: %lld\n", quorum.get());
LogPrintf("knst quorum->qc: %lld\n", quorum->qc.get());
LogPrintf("knst quorum hash: %s\n", quorum->qc->quorumHash.ToString());
/*
LogPrintf("quorum: %lld\n", quorum.get());
LogPrintf("quorum: %lld\n", quorum.get());
LogPrintf("quorum: %lld\n", quorum.get());
LogPrintf("quorum: %lld\n", quorum.get());
LogPrintf("quorum: %lld\n", quorum.get());
LogPrintf("quorum->qc: %lld\n", quorum->qc.get());
LogPrintf("quorum->qc: %lld\n", quorum->qc.get());
LogPrintf("quorum->qc: %lld\n", quorum->qc.get());
LogPrintf("quorum->qc: %lld\n", quorum->qc.get());
LogPrintf("quorum->qc: %lld\n", quorum->qc.get());
LogPrintf("quorum->qc: %lld\n", quorum->qc.get());
LogPrintf("quorum->qc: %lld\n", quorum->qc.get());
LogPrintf("quorum hash: %s\n", quorum->qc->quorumHash.ToString());
*/
MNHFTxPayload mnhfPayload;
mnhfPayload.signal.versionBit = bit;
mnhfPayload.signal.quorumHash = quorum->qc->quorumHash;
Expand All @@ -152,7 +105,6 @@ void CEHFSignalsHandler::HandleNewRecoveredSig(const CRecoveredSig& recoveredSig
if (g_txindex) {
g_txindex->BlockUntilSyncedToCurrentChain();
}
// TODO knst do nothing

LogPrintf("knst Handle new recovered sig: %s!\n", recoveredSig.ToJson().write());

Expand Down
9 changes: 3 additions & 6 deletions src/llmq/ehf_signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ class CEHFSignalsHandler : public CRecoveredSigsListener
CQuorumManager& qman;
CTxMemPool& mempool;
CMNHFManager& mnhfManager;
/* std::unique_ptr<CScheduler> scheduler;
std::unique_ptr<std::thread> scheduler_thread;
*/
public:
explicit CEHFSignalsHandler(CChainState& chainstate, CConnman& connman,
CSigningManager& sigman, CSigSharesManager& shareman,
CQuorumManager& qman, CTxMemPool& mempool,
CMNHFManager& mnhfManager);
~CEHFSignalsHandler();

void Start();
void Stop();

/**
* Since Tip is updated it could be a time to generate EHF Signal
*/
void UpdatedBlockTip(const CBlockIndex* const pindexNew);

/*
Expand All @@ -56,7 +54,6 @@ class CEHFSignalsHandler : public CRecoveredSigsListener
void trySignEHFSignal(int bit, const CBlockIndex* const pindex);
};

//extern std::unique_ptr<CEHFSignalsHandler> ehfSignalsHandler;
} // namespace llmq

#endif // BITCOIN_LLMQ_EHF_SIGNALS_H

0 comments on commit eaf582c

Please sign in to comment.