Fix comparison tool by asking for blocks more aggressively

This commit is contained in:
Matt Corallo 2013-10-25 03:52:53 -04:00
parent e213005177
commit b33b9a6fef
2 changed files with 8 additions and 3 deletions

View File

@ -2355,7 +2355,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
uniqueTx.insert(block.GetTxHash(i)); uniqueTx.insert(block.GetTxHash(i));
} }
if (uniqueTx.size() != block.vtx.size()) if (uniqueTx.size() != block.vtx.size())
return state.DoS(100, error("CheckBlock() : duplicate transaction")); return state.DoS(100, error("CheckBlock() : duplicate transaction"), true);
unsigned int nSigOps = 0; unsigned int nSigOps = 0;
BOOST_FOREACH(const CTransaction& tx, block.vtx) BOOST_FOREACH(const CTransaction& tx, block.vtx)
@ -3783,7 +3783,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
LOCK(cs_main); LOCK(cs_main);
CValidationState state; CValidationState state;
if (ProcessBlock(state, pfrom, &block)) if (ProcessBlock(state, pfrom, &block) || state.CorruptionPossible())
mapAlreadyAskedFor.erase(inv); mapAlreadyAskedFor.erase(inv);
int nDoS = 0; int nDoS = 0;
if (state.IsInvalid(nDoS)) if (state.IsInvalid(nDoS))

View File

@ -946,13 +946,15 @@ private:
MODE_ERROR, // run-time error MODE_ERROR, // run-time error
} mode; } mode;
int nDoS; int nDoS;
bool corruptionPossible;
public: public:
CValidationState() : mode(MODE_VALID), nDoS(0) {} 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) if (mode == MODE_ERROR)
return ret; return ret;
nDoS += level; nDoS += level;
mode = MODE_INVALID; mode = MODE_INVALID;
corruptionPossible = corruptionIn;
return ret; return ret;
} }
bool Invalid(bool ret = false) { bool Invalid(bool ret = false) {
@ -982,6 +984,9 @@ public:
} }
return false; return false;
} }
bool CorruptionPossible() {
return corruptionPossible;
}
}; };
/** An in-memory indexed chain of blocks. */ /** An in-memory indexed chain of blocks. */