From 519a398b265bb989c8cedd5d8d9b8169adb9b679 Mon Sep 17 00:00:00 2001 From: nzsquirrell Date: Tue, 18 Aug 2015 20:02:02 +1200 Subject: [PATCH] fix logic for consecutive-same-algo limit change --- src/main.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 51fc2752..b2237351 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2689,8 +2689,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp) nHeight = pindexPrev->nHeight+1; // Check count of sequence of same algo - if ( (TestNet() && (nHeight > 200)) - || (nHeight > nBlockSequentialAlgoRuleStart) ) + if ( (TestNet() && (nHeight > 200)) || (nHeight > nBlockSequentialAlgoRuleStart)) { int nAlgo = block.GetAlgo(); int nAlgoCount = 1; @@ -2702,17 +2701,23 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp) nAlgoCount++; piPrev = piPrev->pprev; } - if ((nHeight > nBlockSequentialAlgoRuleStart3) && (nAlgoCount > nBlockSequentialAlgoMaxCount3)) + if (nHeight > nBlockSequentialAlgoRuleStart3) { - return state.DoS(100, error("AcceptBlock() : too many blocks from same algo"), + if(nAlgoCount > nBlockSequentialAlgoMaxCount3) + { + return state.DoS(100, error("AcceptBlock() : too many blocks from same algo"), REJECT_INVALID, "algo-toomany"); - } else - if ((nHeight > nBlockSequentialAlgoRuleStart2) && (nAlgoCount > nBlockSequentialAlgoMaxCount2)) + } + } + else if (nHeight > nBlockSequentialAlgoRuleStart2) { - return state.DoS(100, error("AcceptBlock() : too many blocks from same algo"), + if(nAlgoCount > nBlockSequentialAlgoMaxCount2) + { + return state.DoS(100, error("AcceptBlock() : too many blocks from same algo"), REJECT_INVALID, "algo-toomany"); - } else - if (nAlgoCount > nBlockSequentialAlgoMaxCount) + } + } + else if (nAlgoCount > nBlockSequentialAlgoMaxCount) { return state.DoS(100, error("AcceptBlock() : too many blocks from same algo"), REJECT_INVALID, "algo-toomany");