Skip to content

Commit

Permalink
Use proper ReadBlockFromDisk
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquid369 committed Jan 14, 2025
1 parent 00754bd commit 88a8e1e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
11 changes: 10 additions & 1 deletion src/validationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "chain.h"
#include "consensus/validation.h"
#include "evo/deterministicmns.h"
#include "llmq/quorums_chainlocks.h"
#include "logging.h"
#include "scheduler.h"
#include "util/validation.h"
Expand All @@ -30,6 +31,7 @@ struct ValidationInterfaceConnections {
boost::signals2::scoped_connection Broadcast;
boost::signals2::scoped_connection BlockChecked;
boost::signals2::scoped_connection NotifyMasternodeListChanged;
boost::signals2::scoped_connection NotifyChainLock;
};

struct MainSignalsInstance {
Expand All @@ -56,7 +58,8 @@ struct MainSignalsInstance {
boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
/** Notifies listeners of updated deterministic masternode list */
boost::signals2::signal<void (bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff)> NotifyMasternodeListChanged;

/** Notifies listeners of a ChainLock. */
boost::signals2::signal<void (const CBlockIndex* pindex, const llmq::CChainLockSig& clsig)> NotifyChainLock;
std::unordered_map<CValidationInterface*, ValidationInterfaceConnections> m_connMainSignals;

// We are not allowed to assume the scheduler only runs in one thread,
Expand Down Expand Up @@ -108,6 +111,7 @@ void RegisterSharedValidationInterface(std::shared_ptr<CValidationInterface> pwa
conns.Broadcast = g_signals.m_internals->Broadcast.connect(std::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, std::placeholders::_1));
conns.BlockChecked = g_signals.m_internals->BlockChecked.connect(std::bind(&CValidationInterface::BlockChecked, pwalletIn, std::placeholders::_1, std::placeholders::_2));
conns.NotifyMasternodeListChanged = g_signals.m_internals->NotifyMasternodeListChanged.connect(std::bind(&CValidationInterface::NotifyMasternodeListChanged, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
conns.NotifyChainLock = g_signals.m_internals->NotifyChainLock.connect(std::bind(&CValidationInterface::NotifyChainLock, pwalletIn, std::placeholders::_1, std::placeholders::_2));
}
void RegisterValidationInterface(CValidationInterface* pwalletIn)
{
Expand Down Expand Up @@ -249,3 +253,8 @@ void CMainSignals::NotifyMasternodeListChanged(bool undo, const CDeterministicMN
diff.updatedMNs.size(),
diff.removedMns.size());
}

void CMainSignals::NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLockSig& clsig) {
m_internals->NotifyChainLock(pindex, clsig);
LOG_EVENT("%s: new chain lock pindex: %s, CLSIG: %s", __func__, pindex->GetBlockHash().ToString(), clsig.ToString());
}
1 change: 0 additions & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,6 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface

/** notify stake-split threshold changed */
boost::signals2::signal<void (const CAmount stakeSplitThreshold)> NotifySSTChanged;
void NotifyChainLock(const CBlockIndex* pindexChainLock, const llmq::CChainLockSig& clsig) override;
};

/** A key allocated from the key pool. */
Expand Down
1 change: 0 additions & 1 deletion src/zmq/zmqnotificationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class CZMQNotificationInterface : public CValidationInterface
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected);
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const uint256& blockHash, int nBlockHeight, int64_t blockTime);
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload);
void NotifyChainLock(const CBlockIndex *pindex, const llmq::CChainLockSig& clsig);

private:
CZMQNotificationInterface();
Expand Down
6 changes: 2 additions & 4 deletions src/zmq/zmqpublishnotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,11 @@ bool CZMQPublishRawChainLockNotifier::NotifyChainLock(const CBlockIndex *pindex,
{
LogPrint(BCLog::ZMQ, "zmq: Publish rawchainlock %s\n", pindex->GetBlockHash().GetHex());

const Consensus::Params& consensusParams = Params().GetConsensus();
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
{
LOCK(cs_main);
CBlock block;
if(!ReadBlockFromDisk(block, pindex, consensusParams))
if(!ReadBlockFromDisk(block, pindex))
{
zmqError("Can't read block from disk");
return false;
Expand All @@ -223,12 +222,11 @@ bool CZMQPublishRawChainLockSigNotifier::NotifyChainLock(const CBlockIndex *pind
{
LogPrint(BCLog::ZMQ, "zmq: Publish rawchainlocksig %s\n", pindex->GetBlockHash().GetHex());

const Consensus::Params& consensusParams = Params().GetConsensus();
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
{
LOCK(cs_main);
CBlock block;
if(!ReadBlockFromDisk(block, pindex, consensusParams))
if(!ReadBlockFromDisk(block, pindex))
{
zmqError("Can't read block from disk");
return false;
Expand Down

0 comments on commit 88a8e1e

Please sign in to comment.