diff --git a/src/llmq/context.cpp b/src/llmq/context.cpp index 9b8b6bb400..2c6c11446e 100644 --- a/src/llmq/context.cpp +++ b/src/llmq/context.cpp @@ -36,7 +36,8 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis shareman{std::make_unique(connman, *sigman, mn_activeman, *qman, sporkman, peerman)}, clhandler{[&]() -> llmq::CChainLocksHandler* const { assert(llmq::chainLocksHandler == nullptr); - llmq::chainLocksHandler = std::make_unique(chainstate, *qman, *sigman, *shareman, sporkman, mempool, mn_sync, is_masternode); + llmq::chainLocksHandler = std::make_unique(chainstate, *qman, *sigman, *shareman, + sporkman, mempool, mn_sync, is_masternode); return llmq::chainLocksHandler.get(); }()}, isman{[&]() -> llmq::CInstantSendManager* const { @@ -45,7 +46,7 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis return llmq::quorumInstantSendManager.get(); }()}, ehfSignalsHandler{ - std::make_unique(chainstate, mnhfman, *sigman, *shareman, mempool, *qman, peerman)} + std::make_unique(chainstate, mnhfman, *sigman, *shareman, mempool, *qman)} { } diff --git a/src/llmq/ehf_signals.cpp b/src/llmq/ehf_signals.cpp index f9f08eb896..3ea7bf8677 100644 --- a/src/llmq/ehf_signals.cpp +++ b/src/llmq/ehf_signals.cpp @@ -14,7 +14,6 @@ #include #include #include // g_txindex -#include #include #include #include @@ -23,15 +22,13 @@ namespace llmq { CEHFSignalsHandler::CEHFSignalsHandler(CChainState& chainstate, CMNHFManager& mnhfman, CSigningManager& sigman, - CSigSharesManager& shareman, CTxMemPool& mempool, const CQuorumManager& qman, - const std::unique_ptr& peerman) : + CSigSharesManager& shareman, CTxMemPool& mempool, const CQuorumManager& qman) : chainstate(chainstate), mnhfman(mnhfman), sigman(sigman), shareman(shareman), mempool(mempool), - qman(qman), - m_peerman(peerman) + qman(qman) { sigman.RegisterRecoveredSigsListener(this); } @@ -105,6 +102,7 @@ MessageProcessingResult CEHFSignalsHandler::HandleNewRecoveredSig(const CRecover return {}; } + MessageProcessingResult ret; const auto ehfSignals = mnhfman.GetSignalsStage(WITH_LOCK(cs_main, return chainstate.m_chain.Tip())); MNHFTxPayload mnhfPayload; for (const auto& deployment : Params().GetConsensus().vDeployments) { @@ -130,13 +128,13 @@ MessageProcessingResult CEHFSignalsHandler::HandleNewRecoveredSig(const CRecover LOCK(cs_main); const MempoolAcceptResult result = AcceptToMemoryPool(chainstate, mempool, tx_to_sent, /* bypass_limits */ false); if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) { - Assert(m_peerman)->RelayTransaction(tx_to_sent->GetHash()); + ret.m_transactions.push_back(tx_to_sent->GetHash()); } else { LogPrintf("CEHFSignalsHandler::HandleNewRecoveredSig -- AcceptToMemoryPool failed: %s\n", result.m_state.ToString()); } } break; } - return {}; + return ret; } } // namespace llmq diff --git a/src/llmq/ehf_signals.h b/src/llmq/ehf_signals.h index a77c7b8266..41f888d48d 100644 --- a/src/llmq/ehf_signals.h +++ b/src/llmq/ehf_signals.h @@ -13,7 +13,6 @@ class CBlockIndex; class CChainState; class CMNHFManager; class CTxMemPool; -class PeerManager; namespace llmq { @@ -30,7 +29,6 @@ private: CSigSharesManager& shareman; CTxMemPool& mempool; const CQuorumManager& qman; - const std::unique_ptr& m_peerman; /** * keep freshly generated IDs for easier filter sigs in HandleNewRecoveredSig @@ -39,8 +37,8 @@ private: std::set ids GUARDED_BY(cs); public: explicit CEHFSignalsHandler(CChainState& chainstate, CMNHFManager& mnhfman, CSigningManager& sigman, - CSigSharesManager& shareman, CTxMemPool& mempool, const CQuorumManager& qman, - const std::unique_ptr& peerman); + CSigSharesManager& shareman, CTxMemPool& mempool, const CQuorumManager& qman); + ~CEHFSignalsHandler(); diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 1749150484..7332c36b06 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3318,6 +3318,9 @@ void PeerManagerImpl::PostProcessMessage(MessageProcessingResult&& result, NodeI if (result.m_to_erase) { WITH_LOCK(cs_main, EraseObjectRequest(node, result.m_to_erase.value())); } + for (const auto& tx : result.m_transactions) { + WITH_LOCK(cs_main, RelayTransaction(tx)); + } if (result.m_inventory) { RelayInv(result.m_inventory.value(), MIN_PEER_PROTO_VERSION); } diff --git a/src/protocol.h b/src/protocol.h index 9d973a127c..1ba1b8a5e2 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -585,6 +585,7 @@ struct MessageProcessingResult { std::optional m_error; std::optional m_inventory; + std::vector m_transactions; std::optional m_to_erase; MessageProcessingResult() = default; diff --git a/test/lint/lint-circular-dependencies.sh b/test/lint/lint-circular-dependencies.sh index 42e3083a56..a4df9d5a4b 100755 --- a/test/lint/lint-circular-dependencies.sh +++ b/test/lint/lint-circular-dependencies.sh @@ -88,7 +88,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=( "coinjoin/client -> net_processing -> coinjoin/context -> coinjoin/client" "coinjoin/context -> coinjoin/server -> net_processing -> coinjoin/context" "coinjoin/server -> net_processing -> coinjoin/server" - "llmq/context -> llmq/ehf_signals -> net_processing -> llmq/context" + "llmq/context -> llmq/instantsend -> net_processing -> llmq/context" "llmq/chainlocks -> llmq/instantsend -> net_processing -> llmq/chainlocks" "net_processing -> spork -> net_processing" "governance/governance -> net_processing -> governance/governance"