Auto merge of #3452 - LarryRuane:3399-peer-ban-test, r=bitcartel
Test peer banning logic in both pre- and post-initial block download states The DoS ban scores are different for each, and it's nice to test both. Follow-on from #3410.
This commit is contained in:
12
src/main.cpp
12
src/main.cpp
@@ -877,8 +877,14 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
|
||||
* 1. AcceptToMemoryPool calls CheckTransaction and this function.
|
||||
* 2. ProcessNewBlock calls AcceptBlock, which calls CheckBlock (which calls CheckTransaction)
|
||||
* and ContextualCheckBlock (which calls this function).
|
||||
* 3. The isInitBlockDownload argument is only to assist with testing.
|
||||
*/
|
||||
bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state, const int nHeight, const int dosLevel)
|
||||
bool ContextualCheckTransaction(
|
||||
const CTransaction& tx,
|
||||
CValidationState &state,
|
||||
const int nHeight,
|
||||
const int dosLevel,
|
||||
bool (*isInitBlockDownload)())
|
||||
{
|
||||
bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
@@ -886,7 +892,7 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state,
|
||||
|
||||
// If Sprout rules apply, reject transactions which are intended for Overwinter and beyond
|
||||
if (isSprout && tx.fOverwintered) {
|
||||
return state.DoS(IsInitialBlockDownload() ? 0 : dosLevel,
|
||||
return state.DoS(isInitBlockDownload() ? 0 : dosLevel,
|
||||
error("ContextualCheckTransaction(): overwinter is not active yet"),
|
||||
REJECT_INVALID, "tx-overwinter-not-active");
|
||||
}
|
||||
@@ -987,7 +993,7 @@ bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state,
|
||||
dataToBeSigned.begin(), 32,
|
||||
tx.joinSplitPubKey.begin()
|
||||
) != 0) {
|
||||
return state.DoS(IsInitialBlockDownload() ? 0 : 100,
|
||||
return state.DoS(isInitBlockDownload() ? 0 : 100,
|
||||
error("CheckTransaction(): invalid joinsplit signature"),
|
||||
REJECT_INVALID, "bad-txns-invalid-joinsplit-signature");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user