reorder operations in decrementBlock

This commit is contained in:
Jimmy Kiselak 2015-12-29 16:36:06 -05:00
parent 4d3c19e626
commit 76d4b51843

View file

@ -2178,24 +2178,17 @@ bool CClaimTrieCache::decrementBlock(claimQueueRowType& insertUndo, claimQueueRo
{ {
LogPrintf("%s: nCurrentHeight (before decrement): %d\n", __func__, nCurrentHeight); LogPrintf("%s: nCurrentHeight (before decrement): %d\n", __func__, nCurrentHeight);
nCurrentHeight--; nCurrentHeight--;
for (claimQueueRowType::iterator itInsertUndo = insertUndo.begin(); itInsertUndo != insertUndo.end(); ++itInsertUndo)
if (expireSupportUndo.begin() != expireSupportUndo.end())
{ {
claimQueueType::iterator itQueueRow = getQueueCacheRow(itInsertUndo->second.nValidAtHeight, true); supportQueueType::iterator itSupportExpireRow = getSupportExpirationQueueCacheRow(nCurrentHeight, true);
CClaimValue claim; for (supportQueueRowType::iterator itSupportExpireUndo = expireSupportUndo.begin(); itSupportExpireUndo != expireSupportUndo.end(); ++itSupportExpireUndo)
assert(removeClaimFromTrie(itInsertUndo->first, itInsertUndo->second.outPoint, claim, false));
claimQueueNamesType::iterator itQueueNameRow = getQueueCacheNameRow(itInsertUndo->first, true);
itQueueRow->second.push_back(std::make_pair(itInsertUndo->first, claim));
itQueueNameRow->second.push_back(std::make_pair(itInsertUndo->second.outPoint, itInsertUndo->second.nValidAtHeight));
}
if (expireUndo.begin() != expireUndo.end())
{
claimQueueType::iterator itExpireRow = getExpirationQueueCacheRow(nCurrentHeight, true);
for (claimQueueRowType::iterator itExpireUndo = expireUndo.begin(); itExpireUndo != expireUndo.end(); ++itExpireUndo)
{ {
insertClaimIntoTrie(itExpireUndo->first, itExpireUndo->second, false); insertSupportIntoMap(itSupportExpireUndo->first, itSupportExpireUndo->second, false);
itExpireRow->second.push_back(*itExpireUndo); itSupportExpireRow->second.push_back(*itSupportExpireUndo);
} }
} }
for (supportQueueRowType::iterator itSupportUndo = insertSupportUndo.begin(); itSupportUndo != insertSupportUndo.end(); ++itSupportUndo) for (supportQueueRowType::iterator itSupportUndo = insertSupportUndo.begin(); itSupportUndo != insertSupportUndo.end(); ++itSupportUndo)
{ {
supportQueueType::iterator itSupportRow = getSupportQueueCacheRow(itSupportUndo->second.nValidAtHeight, true); supportQueueType::iterator itSupportRow = getSupportQueueCacheRow(itSupportUndo->second.nValidAtHeight, true);
@ -2205,16 +2198,27 @@ bool CClaimTrieCache::decrementBlock(claimQueueRowType& insertUndo, claimQueueRo
itSupportRow->second.push_back(*itSupportUndo); itSupportRow->second.push_back(*itSupportUndo);
itSupportNameRow->second.push_back(itSupportUndo->second); itSupportNameRow->second.push_back(itSupportUndo->second);
} }
if (expireSupportUndo.begin() != expireSupportUndo.end())
if (expireUndo.begin() != expireUndo.end())
{ {
supportQueueType::iterator itSupportExpireRow = getSupportExpirationQueueCacheRow(nCurrentHeight, true); claimQueueType::iterator itExpireRow = getExpirationQueueCacheRow(nCurrentHeight, true);
for (supportQueueRowType::iterator itSupportExpireUndo = expireSupportUndo.begin(); itSupportExpireUndo != expireSupportUndo.end(); ++itSupportExpireUndo) for (claimQueueRowType::iterator itExpireUndo = expireUndo.begin(); itExpireUndo != expireUndo.end(); ++itExpireUndo)
{ {
insertSupportIntoMap(itSupportExpireUndo->first, itSupportExpireUndo->second, false); insertClaimIntoTrie(itExpireUndo->first, itExpireUndo->second, false);
itSupportExpireRow->second.push_back(*itSupportExpireUndo); itExpireRow->second.push_back(*itExpireUndo);
} }
} }
for (claimQueueRowType::iterator itInsertUndo = insertUndo.begin(); itInsertUndo != insertUndo.end(); ++itInsertUndo)
{
claimQueueType::iterator itQueueRow = getQueueCacheRow(itInsertUndo->second.nValidAtHeight, true);
CClaimValue claim;
assert(removeClaimFromTrie(itInsertUndo->first, itInsertUndo->second.outPoint, claim, false));
claimQueueNamesType::iterator itQueueNameRow = getQueueCacheNameRow(itInsertUndo->first, true);
itQueueRow->second.push_back(std::make_pair(itInsertUndo->first, claim));
itQueueNameRow->second.push_back(std::make_pair(itInsertUndo->second.outPoint, itInsertUndo->second.nValidAtHeight));
}
for (std::vector<std::pair<std::string, int> >::iterator itTakeoverHeightUndo = takeoverHeightUndo.begin(); itTakeoverHeightUndo != takeoverHeightUndo.end(); ++itTakeoverHeightUndo) for (std::vector<std::pair<std::string, int> >::iterator itTakeoverHeightUndo = takeoverHeightUndo.begin(); itTakeoverHeightUndo != takeoverHeightUndo.end(); ++itTakeoverHeightUndo)
{ {
cacheTakeoverHeights[itTakeoverHeightUndo->first] = itTakeoverHeightUndo->second; cacheTakeoverHeights[itTakeoverHeightUndo->first] = itTakeoverHeightUndo->second;