Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/llmq/quorums_instantsend.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019 The Axe Core developers
// Copyright (c) 2019 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -937,11 +937,12 @@ void CInstantSendManager::SyncTransaction(const CTransaction& tx, const CBlockIn
}

bool inMempool = mempool.get(tx.GetHash()) != nullptr;
bool isDisconnect = pindex && posInBlock == CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK;

// Are we called from validation.cpp/MemPoolConflictRemovalTracker?
// TODO refactor this when we backport the BlockConnected signal from Bitcoin, as it gives better info about
// conflicted TXs
bool isConflictRemoved = !pindex && posInBlock == CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK && !inMempool;
bool isConflictRemoved = isDisconnect && !inMempool;

if (isConflictRemoved) {
LOCK(cs);
Expand All @@ -956,8 +957,9 @@ void CInstantSendManager::SyncTransaction(const CTransaction& tx, const CBlockIn

// update DB about when an IS lock was mined
if (!islockHash.IsNull() && pindex) {
if (posInBlock == CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK) {
db.RemoveInstantSendLockMined(islockHash, pindex->nHeight);
if (isDisconnect) {
// SyncTransaction is called with pprev
db.RemoveInstantSendLockMined(islockHash, pindex->nHeight + 1);
} else {
db.WriteInstantSendLockMined(islockHash, pindex->nHeight);
}
Expand All @@ -977,7 +979,7 @@ void CInstantSendManager::SyncTransaction(const CTransaction& tx, const CBlockIn
if (!chainlocked && islockHash.IsNull()) {
// TX is not locked, so make sure it is tracked
AddNonLockedTx(MakeTransactionRef(tx));
nonLockedTxs.at(tx.GetHash()).pindexMined = posInBlock != CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK ? pindex : nullptr;
nonLockedTxs.at(tx.GetHash()).pindexMined = !isDisconnect ? pindex : nullptr;
} else {
// TX is locked, so make sure we don't track it anymore
RemoveNonLockedTx(tx.GetHash(), true);
Expand Down