Skip to content

Commit

Permalink
Remove redundant parameter fCheckDuplicateInputs from CheckTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
masi committed Dec 16, 2018
1 parent 3e93998 commit 14cb46e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ int GetUTXOConfirmations(const COutPoint& outpoint)
}


bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fCheckDuplicateInputs)
bool CheckTransaction(const CTransaction& tx, CValidationState &state)
{
// Basic checks that don't depend on any context
if (tx.vin.empty())
Expand All @@ -498,14 +498,12 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe
return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge");
}

// Check for duplicate inputs - note that this check is slow so we skip it in CheckBlock
if (fCheckDuplicateInputs) {
set<COutPoint> vInOutPoints;
for (const auto& txin : tx.vin)
{
if (!vInOutPoints.insert(txin.prevout).second)
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputs-duplicate");
}
// Check for duplicate inputs
std::set<COutPoint> vInOutPoints;
for (const auto& txin : tx.vin)
{
if (!vInOutPoints.insert(txin.prevout).second)
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputs-duplicate");
}

if (tx.IsCoinBase())
Expand Down Expand Up @@ -3171,7 +3169,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo

// Check transactions
for (const auto& tx : block.vtx)
if (!CheckTransaction(tx, state, true))
if (!CheckTransaction(tx, state))
return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(),
strprintf("Transaction check failed (tx hash %s) %s", tx.GetHash().ToString(), state.GetDebugMessage()));

Expand Down
2 changes: 1 addition & 1 deletion src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight);

/** Context-independent validity checks */
bool CheckTransaction(const CTransaction& tx, CValidationState& state, bool fCheckDuplicateInputs=true);
bool CheckTransaction(const CTransaction& tx, CValidationState& state);

/**
* Check if transaction is final and can be included in a block with the
Expand Down

0 comments on commit 14cb46e

Please sign in to comment.