From b36f0a324f2446a326339bd15a238f4af74c7e6a Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Mon, 27 May 2019 13:35:22 +0200 Subject: [PATCH] Call new signals instead of SyncTransaction on CInstantSendManager This commit moves all logic of SyncTransaction into ProcessNewTransaction and then calls it from TransactionAddedToMempool and BlockConnected. This won't compile/work at first, but the next commits will fix this. --- src/dsnotificationinterface.cpp | 6 +++++- src/llmq/quorums_instantsend.cpp | 22 +++++++++++++++++++++- src/llmq/quorums_instantsend.h | 5 ++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index 33cc5e8e77..0a18570d42 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -74,7 +74,6 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con void CDSNotificationInterface::SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex, int posInBlock) { - llmq::quorumInstantSendManager->SyncTransaction(tx, pindex, posInBlock); llmq::chainLocksHandler->SyncTransaction(tx, pindex, posInBlock); instantsend.SyncTransaction(tx, pindex, posInBlock); CPrivateSend::SyncTransaction(tx, pindex, posInBlock); @@ -82,6 +81,7 @@ void CDSNotificationInterface::SyncTransaction(const CTransactionRef& tx, const void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx) { + llmq::quorumInstantSendManager->TransactionAddedToMempool(ptx); SyncTransaction(ptx); } @@ -95,6 +95,8 @@ void CDSNotificationInterface::BlockConnected(const std::shared_ptrBlockConnected(pblock, pindex, vtxConflicted); + for (const CTransactionRef& ptx : vtxConflicted) { SyncTransaction(ptx); } @@ -105,6 +107,8 @@ void CDSNotificationInterface::BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindexDisconnected) { + llmq::quorumInstantSendManager->BlockDisconnected(pblock, pindexDisconnected); + for (const CTransactionRef& ptx : pblock->vtx) { SyncTransaction(ptx, pindexDisconnected->pprev, -1); } diff --git a/src/llmq/quorums_instantsend.cpp b/src/llmq/quorums_instantsend.cpp index 24ce9f39eb..dd16533ef4 100644 --- a/src/llmq/quorums_instantsend.cpp +++ b/src/llmq/quorums_instantsend.cpp @@ -949,7 +949,7 @@ void CInstantSendManager::UpdateWalletTransaction(const CTransactionRef& tx, con mempool.AddTransactionsUpdated(1); } -void CInstantSendManager::SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex, int posInBlock) +void CInstantSendManager::ProcessNewTransaction(const CTransactionRef& tx, const CBlockIndex* pindex) { if (!IsNewInstantSendEnabled()) { return; @@ -1008,6 +1008,26 @@ void CInstantSendManager::SyncTransaction(const CTransactionRef& tx, const CBloc } } +void CInstantSendManager::TransactionAddedToMempool(const CTransactionRef& tx) +{ + ProcessNewTransaction(tx, nullptr); +} + +void CInstantSendManager::BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindex, const std::vector& vtxConflicted) +{ + if (!IsNewInstantSendEnabled()) { + return; + } + + for (const auto& tx : pblock->vtx) { + ProcessNewTransaction(tx, pindex); + } +} + +void CInstantSendManager::BlockDisconnected(const std::shared_ptr& pblock, const CBlockIndex* pindexDisconnected) +{ +} + void CInstantSendManager::AddNonLockedTx(const CTransactionRef& tx) { AssertLockHeld(cs); diff --git a/src/llmq/quorums_instantsend.h b/src/llmq/quorums_instantsend.h index 4f2811c6b0..4ba1e3a678 100644 --- a/src/llmq/quorums_instantsend.h +++ b/src/llmq/quorums_instantsend.h @@ -141,7 +141,10 @@ public: void ProcessInstantSendLock(NodeId from, const uint256& hash, const CInstantSendLock& islock); void UpdateWalletTransaction(const CTransactionRef& tx, const CInstantSendLock& islock); - void SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex = nullptr, int posInBlock = 0); + void ProcessNewTransaction(const CTransactionRef& tx, const CBlockIndex* pindex); + void TransactionAddedToMempool(const CTransactionRef& tx); + void BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindex, const std::vector& vtxConflicted); + void BlockDisconnected(const std::shared_ptr& pblock, const CBlockIndex* pindexDisconnected); void AddNonLockedTx(const CTransactionRef& tx); void RemoveNonLockedTx(const uint256& txid, bool retryChildren); void RemoveConflictedTx(const CTransaction& tx);