Skip to content

Commit

Permalink
Enforce IX locks from the new system
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Mar 7, 2019
1 parent dc97835 commit 7945192
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "evo/deterministicmns.h"
#include "evo/cbtx.h"

#include "llmq/quorums_instantsend.h"
#include "llmq/quorums_chainlocks.h"

#include <atomic>
Expand Down Expand Up @@ -692,6 +693,18 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
REJECT_INVALID, "tx-txlock-conflict");
}

uint256 txConflictHash;
if (llmq::quorumInstantSendManager->GetConflictingTx(tx, txConflictHash)) {
CTransactionRef txConflict;
uint256 hashBlock;
if (GetTransaction(txConflictHash, txConflict, Params().GetConsensus(), hashBlock)) {
GetMainSignals().NotifyInstantSendDoubleSpendAttempt(tx, *txConflict);
}
return state.DoS(10, error("AcceptToMemoryPool : Transaction %s conflicts with locked TX %s",
hash.ToString(), txConflictHash.ToString()),
REJECT_INVALID, "tx-txlock-conflict");
}

// Check for conflicts with in-memory transactions
{
LOCK(pool.cs); // protect pool.mapNextTx
Expand Down Expand Up @@ -3278,6 +3291,15 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
strprintf("transaction %s conflicts with transaction lock %s", tx->GetHash().ToString(), hashLocked.ToString()));
}
}
uint256 txConflict;
if (llmq::quorumInstantSendManager->GetConflictingTx(*tx, txConflict)) {
// The node which relayed this will have to switch later,
// relaying instantsend data won't help it.
LOCK(cs_main);
mapRejectedBlocks.insert(std::make_pair(block.GetHash(), GetTime()));
return state.DoS(100, false, REJECT_INVALID, "conflict-tx-lock", false,
strprintf("transaction %s conflicts with transaction lock %s", tx->GetHash().ToString(), txConflict.ToString()));
}
}
} else {
LogPrintf("CheckBlock(DASH): spork is off, skipping transaction locking checks\n");
Expand Down

0 comments on commit 7945192

Please sign in to comment.