From 715a3e9518dedb1df095916ae63a5d68fc2b1064 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Mon, 27 May 2019 13:56:04 +0200 Subject: [PATCH] Move updating of txFirstSeenTime into TransactionAddedToMempool and BlockConnected This removes the need for SyncTransaction --- src/llmq/quorums_chainlocks.cpp | 32 +++++++++++++------------------- src/llmq/quorums_chainlocks.h | 1 - 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/llmq/quorums_chainlocks.cpp b/src/llmq/quorums_chainlocks.cpp index e079fd4ba5..827730d727 100644 --- a/src/llmq/quorums_chainlocks.cpp +++ b/src/llmq/quorums_chainlocks.cpp @@ -347,7 +347,17 @@ void CChainLocksHandler::TrySignChainTip() void CChainLocksHandler::TransactionAddedToMempool(const CTransactionRef& tx) { + if (tx->IsCoinBase() || tx->vin.empty()) { + return; + } + if (!masternodeSync.IsBlockchainSynced()) { + return; + } + + LOCK(cs); + int64_t curTime = GetAdjustedTime(); + txFirstSeenTime.emplace(tx->GetHash(), curTime); } void CChainLocksHandler::BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindex, const std::vector& vtxConflicted) @@ -370,12 +380,15 @@ void CChainLocksHandler::BlockConnected(const std::shared_ptr& pbl } auto& txids = *it->second; + int64_t curTime = GetAdjustedTime(); + for (const auto& tx : pblock->vtx) { if (tx->IsCoinBase() || tx->vin.empty()) { continue; } txids.emplace(tx->GetHash()); + txFirstSeenTime.emplace(tx->GetHash(), curTime); } } @@ -386,25 +399,6 @@ void CChainLocksHandler::BlockDisconnected(const std::shared_ptr& blockTxs.erase(pindexDisconnected->GetBlockHash()); } -void CChainLocksHandler::SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex, int posInBlock) -{ - if (!masternodeSync.IsBlockchainSynced()) { - return; - } - - bool handleTx = true; - if (tx->IsCoinBase() || tx->vin.empty()) { - handleTx = false; - } - - LOCK(cs); - - if (handleTx) { - int64_t curTime = GetAdjustedTime(); - txFirstSeenTime.emplace(tx->GetHash(), curTime); - } -} - CChainLocksHandler::BlockTxs::mapped_type CChainLocksHandler::GetBlockTxs(const uint256& blockHash) { AssertLockNotHeld(cs); diff --git a/src/llmq/quorums_chainlocks.h b/src/llmq/quorums_chainlocks.h index 684a4b8385..36308b28e0 100644 --- a/src/llmq/quorums_chainlocks.h +++ b/src/llmq/quorums_chainlocks.h @@ -93,7 +93,6 @@ public: 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 SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex = nullptr, int posInBlock = 0); void CheckActiveState(); void TrySignChainTip(); void EnforceBestChainLock();