From 8ede0c3460e2880c1fe33fed42eb4e6270076b8f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 25 Oct 2013 03:52:53 -0400 Subject: [PATCH] Fix comparison tool by asking for blocks more aggressively Rebased-from: b33b9a6fefbe832bf45a6c7717d0537f27597bff --- src/main.cpp | 4 ++-- src/main.h | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b09f3cfea..c8672e1db 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2131,7 +2131,7 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk uniqueTx.insert(GetTxHash(i)); } if (uniqueTx.size() != vtx.size()) - return state.DoS(100, error("CheckBlock() : duplicate transaction")); + return state.DoS(100, error("CheckBlock() : duplicate transaction"), true); unsigned int nSigOps = 0; BOOST_FOREACH(const CTransaction& tx, vtx) @@ -3630,7 +3630,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) pfrom->AddInventoryKnown(inv); CValidationState state; - if (ProcessBlock(state, pfrom, &block)) + if (ProcessBlock(state, pfrom, &block) || state.CorruptionPossible()) mapAlreadyAskedFor.erase(inv); int nDoS = 0; if (state.IsInvalid(nDoS)) diff --git a/src/main.h b/src/main.h index 015cf263f..af039f99b 100644 --- a/src/main.h +++ b/src/main.h @@ -1907,13 +1907,15 @@ private: MODE_ERROR, // run-time error } mode; int nDoS; + bool corruptionPossible; public: CValidationState() : mode(MODE_VALID), nDoS(0) {} - bool DoS(int level, bool ret = false) { + bool DoS(int level, bool ret = false, bool corruptionIn = false) { if (mode == MODE_ERROR) return ret; nDoS += level; mode = MODE_INVALID; + corruptionPossible = corruptionIn; return ret; } bool Invalid(bool ret = false) { @@ -1943,6 +1945,9 @@ public: } return false; } + bool CorruptionPossible() { + return corruptionPossible; + } };