Move updating of txFirstSeenTime into TransactionAddedToMempool and BlockConnected

This removes the need for SyncTransaction
This commit is contained in:
Alexander Block 2019-05-27 13:56:04 +02:00
parent a61127e1ae
commit 715a3e9518
2 changed files with 13 additions and 20 deletions

View File

@ -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<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
@ -370,12 +380,15 @@ void CChainLocksHandler::BlockConnected(const std::shared_ptr<const CBlock>& 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<const CBlock>&
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);

View File

@ -93,7 +93,6 @@ public:
void TransactionAddedToMempool(const CTransactionRef& tx);
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted);
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected);
void SyncTransaction(const CTransactionRef& tx, const CBlockIndex* pindex = nullptr, int posInBlock = 0);
void CheckActiveState();
void TrySignChainTip();
void EnforceBestChainLock();