add cache for mn rank lookup
@@ -22,6 +22,7 @@ CCriticalSection cs_fortunastakes;
std::vector<CFortunaStake> vecFortunastakes;
std::vector<pair<int, CFortunaStake*> > vecFortunastakeScores;
std::vector<CFortunaStake> vecFortunastakeScoresList;
+uint256 vecFortunastakeScoresListHash;
std::vector<pair<int, CFortunaStake> > vecFortunastakeRanks;
/** Object for who's going to get paid on which blocks */
CFortunastakePayments fortunastakePayments;
@@ -515,7 +516,16 @@ bool GetFortunastakeRanks(CBlockIndex* pindex)
if (!pindex || IsInitialBlockDownload() || pindex->GetBlockTime() < GetTime() - 30*nCoinbaseMaturity) return true;
vecFortunastakeScores.clear();
+ int i;
+ if (vecFortunastakeScoresListHash == pindex->GetBlockHash()) {
+ BOOST_FOREACH(CFortunaStake& mn, vecFortunastakeScoresList)
+ {
+ i++;
+ vecFortunastakeScores.push_back(make_pair(i, &mn));
+ }
+ } else {
vecFortunastakeScoresList.clear();
+
BOOST_FOREACH(CFortunaStake& mn, vecFortunastakes) {
mn.Check();
@@ -529,6 +539,8 @@ bool GetFortunastakeRanks(CBlockIndex* pindex)
vecFortunastakeScoresList.push_back(mn);
}
+ vecFortunastakeScoresListHash = pindex->GetBlockHash();
+ }
// NO MORE TODO: Store the Scores vector in a caching hash map, maybe need hashPrev as well to make sure it re calculates any different chains with the same end block?
//vecFortunastakeScoresCache.insert(make_pair(pindex->GetBlockHash(), vecFortunastakeScoresList));
