From 1ca4abe444e480434fd6d2ce061ae986bc506acc Mon Sep 17 00:00:00 2001 From: miketout Date: Fri, 12 Oct 2018 22:41:43 -0700 Subject: [PATCH] Cleanup cheatcatcher --- src/cheatcatcher.cpp | 8 ++++++++ src/cheatcatcher.h | 7 +------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cheatcatcher.cpp b/src/cheatcatcher.cpp index e896b2c1f..86d19ddee 100644 --- a/src/cheatcatcher.cpp +++ b/src/cheatcatcher.cpp @@ -45,6 +45,13 @@ uint32_t CCheatList::Prune(uint32_t height) bool GetStakeParams(const CTransaction &stakeTx, CStakeParams &stakeParams); +bool CCheatList::IsHeightOrGreaterInList(uint32_t height) +{ + auto range = orderedCheatCandidates.equal_range(height); + //printf("IsHeightOrGreaterInList: %s\n", range.second == orderedCheatCandidates.end() ? "false" : "true"); + return (range.second != orderedCheatCandidates.end()); +} + bool CCheatList::IsCheatInList(const CTransaction &tx, CTransaction *cheatTx) { // for a tx to be cheat, it needs to spend the same UTXO and be for a different prior block @@ -92,6 +99,7 @@ bool CCheatList::Add(const CTxHolder &txh) LOCK(cs_cheat); auto it = orderedCheatCandidates.insert(pair(txh.height, txh)); indexedCheatCandidates.insert(pair(txh.utxo, &it->second)); + printf("CCheatList::Add orderedCheatCandidates.size: %d, indexedCheatCandidates.size: %d\n", orderedCheatCandidates.size(), indexedCheatCandidates.size()); } } diff --git a/src/cheatcatcher.h b/src/cheatcatcher.h index 8193c823a..dfce7a1db 100644 --- a/src/cheatcatcher.h +++ b/src/cheatcatcher.h @@ -62,12 +62,7 @@ class CCheatList bool IsCheatInList(const CTransaction &tx, CTransaction *pcheatTx); // check to see if there are cheat candidates of the same or greater block height in list - bool IsHeightOrGreaterInList(uint32_t height) - { - auto range = orderedCheatCandidates.equal_range(height); - //printf("IsHeightOrGreaterInList: %s\n", range.second == orderedCheatCandidates.end() ? "false" : "true"); - return (range.second == orderedCheatCandidates.end()); - } + bool IsHeightOrGreaterInList(uint32_t height); // add a potential cheat transaction to the list. we do this for all stake transactions from orphaned stakes bool Add(const CTxHolder &txh);