Auto merge of #3148 - str4d:DOS-mitigation-tx-expiry, r=str4d

Don't increase banscore for expired transactions if they only just expired

Closes #3141.
This commit is contained in:
Homu
2018-04-04 15:46:25 -07:00
4 changed files with 173 additions and 5 deletions

View File

@@ -897,7 +897,9 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state,
// Check that all transactions are unexpired
if (IsExpiredTx(tx, nHeight)) {
return state.DoS(dosLevel, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired");
// Don't increase banscore if the transaction only just expired
int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? dosLevel : 0;
return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction is expired"), REJECT_INVALID, "tx-overwinter-expired");
}
}