change type of expiration queue
This commit is contained in:
parent
1f9a22d62e
commit
5a170adab8
4 changed files with 181 additions and 157 deletions
|
@ -175,7 +175,7 @@ bool CClaimTrie::queueEmpty() const
|
||||||
|
|
||||||
bool CClaimTrie::expirationQueueEmpty() const
|
bool CClaimTrie::expirationQueueEmpty() const
|
||||||
{
|
{
|
||||||
for (claimQueueType::const_iterator itRow = dirtyExpirationQueueRows.begin(); itRow != dirtyExpirationQueueRows.end(); ++itRow)
|
for (expirationQueueType::const_iterator itRow = dirtyExpirationQueueRows.begin(); itRow != dirtyExpirationQueueRows.end(); ++itRow)
|
||||||
{
|
{
|
||||||
if (!itRow->second.empty())
|
if (!itRow->second.empty())
|
||||||
return false;
|
return false;
|
||||||
|
@ -255,12 +255,12 @@ bool CClaimTrie::haveSupport(const std::string& name, const COutPoint& outPoint)
|
||||||
|
|
||||||
bool CClaimTrie::haveClaimInQueue(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight) const
|
bool CClaimTrie::haveClaimInQueue(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight) const
|
||||||
{
|
{
|
||||||
outPointHeightRowType nameRow;
|
queueNameRowType nameRow;
|
||||||
if (!getQueueNameRow(name, nameRow))
|
if (!getQueueNameRow(name, nameRow))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
outPointHeightRowType::const_iterator itNameRow;
|
queueNameRowType::const_iterator itNameRow;
|
||||||
for (itNameRow = nameRow.begin(); itNameRow != nameRow.end(); ++itNameRow)
|
for (itNameRow = nameRow.begin(); itNameRow != nameRow.end(); ++itNameRow)
|
||||||
{
|
{
|
||||||
if (itNameRow->outPoint == outPoint)
|
if (itNameRow->outPoint == outPoint)
|
||||||
|
@ -294,12 +294,12 @@ bool CClaimTrie::haveClaimInQueue(const std::string& name, const COutPoint& outP
|
||||||
|
|
||||||
bool CClaimTrie::haveSupportInQueue(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight) const
|
bool CClaimTrie::haveSupportInQueue(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight) const
|
||||||
{
|
{
|
||||||
outPointHeightRowType nameRow;
|
queueNameRowType nameRow;
|
||||||
if (!getSupportQueueNameRow(name, nameRow))
|
if (!getSupportQueueNameRow(name, nameRow))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
outPointHeightRowType::const_iterator itNameRow;
|
queueNameRowType::const_iterator itNameRow;
|
||||||
for (itNameRow = nameRow.begin(); itNameRow != nameRow.end(); ++itNameRow)
|
for (itNameRow = nameRow.begin(); itNameRow != nameRow.end(); ++itNameRow)
|
||||||
{
|
{
|
||||||
if (itNameRow->outPoint == outPoint)
|
if (itNameRow->outPoint == outPoint)
|
||||||
|
@ -499,9 +499,9 @@ bool CClaimTrie::getQueueRow(int nHeight, claimQueueRowType& row) const
|
||||||
return db.Read(std::make_pair(CLAIM_QUEUE_ROW, nHeight), row);
|
return db.Read(std::make_pair(CLAIM_QUEUE_ROW, nHeight), row);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrie::getQueueNameRow(const std::string& name, outPointHeightRowType& row) const
|
bool CClaimTrie::getQueueNameRow(const std::string& name, queueNameRowType& row) const
|
||||||
{
|
{
|
||||||
nameOutPointHeightMapType::const_iterator itQueueNameRow = dirtyQueueNameRows.find(name);
|
queueNameType::const_iterator itQueueNameRow = dirtyQueueNameRows.find(name);
|
||||||
if (itQueueNameRow != dirtyQueueNameRows.end())
|
if (itQueueNameRow != dirtyQueueNameRows.end())
|
||||||
{
|
{
|
||||||
row = itQueueNameRow->second;
|
row = itQueueNameRow->second;
|
||||||
|
@ -510,9 +510,9 @@ bool CClaimTrie::getQueueNameRow(const std::string& name, outPointHeightRowType&
|
||||||
return db.Read(std::make_pair(CLAIM_QUEUE_NAME_ROW, name), row);
|
return db.Read(std::make_pair(CLAIM_QUEUE_NAME_ROW, name), row);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrie::getExpirationQueueRow(int nHeight, claimQueueRowType& row) const
|
bool CClaimTrie::getExpirationQueueRow(int nHeight, expirationQueueRowType& row) const
|
||||||
{
|
{
|
||||||
claimQueueType::const_iterator itQueueRow = dirtyExpirationQueueRows.find(nHeight);
|
expirationQueueType::const_iterator itQueueRow = dirtyExpirationQueueRows.find(nHeight);
|
||||||
if (itQueueRow != dirtyExpirationQueueRows.end())
|
if (itQueueRow != dirtyExpirationQueueRows.end())
|
||||||
{
|
{
|
||||||
row = itQueueRow->second;
|
row = itQueueRow->second;
|
||||||
|
@ -535,28 +535,28 @@ void CClaimTrie::updateQueueRow(int nHeight, claimQueueRowType& row)
|
||||||
itQueueRow->second.swap(row);
|
itQueueRow->second.swap(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClaimTrie::updateQueueNameRow(const std::string& name, outPointHeightRowType& row)
|
void CClaimTrie::updateQueueNameRow(const std::string& name, queueNameRowType& row)
|
||||||
{
|
{
|
||||||
nameOutPointHeightMapType::iterator itQueueRow = dirtyQueueNameRows.find(name);
|
queueNameType::iterator itQueueRow = dirtyQueueNameRows.find(name);
|
||||||
if (itQueueRow == dirtyQueueNameRows.end())
|
if (itQueueRow == dirtyQueueNameRows.end())
|
||||||
{
|
{
|
||||||
outPointHeightRowType newRow;
|
queueNameRowType newRow;
|
||||||
std::pair<nameOutPointHeightMapType::iterator, bool> ret;
|
std::pair<queueNameType::iterator, bool> ret;
|
||||||
ret = dirtyQueueNameRows.insert(std::pair<std::string, outPointHeightRowType>(name, newRow));
|
ret = dirtyQueueNameRows.insert(std::pair<std::string, queueNameRowType>(name, newRow));
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
itQueueRow = ret.first;
|
itQueueRow = ret.first;
|
||||||
}
|
}
|
||||||
itQueueRow->second.swap(row);
|
itQueueRow->second.swap(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClaimTrie::updateExpirationRow(int nHeight, claimQueueRowType& row)
|
void CClaimTrie::updateExpirationRow(int nHeight, expirationQueueRowType& row)
|
||||||
{
|
{
|
||||||
claimQueueType::iterator itQueueRow = dirtyExpirationQueueRows.find(nHeight);
|
expirationQueueType::iterator itQueueRow = dirtyExpirationQueueRows.find(nHeight);
|
||||||
if (itQueueRow == dirtyExpirationQueueRows.end())
|
if (itQueueRow == dirtyExpirationQueueRows.end())
|
||||||
{
|
{
|
||||||
claimQueueRowType newRow;
|
expirationQueueRowType newRow;
|
||||||
std::pair<claimQueueType::iterator, bool> ret;
|
std::pair<expirationQueueType::iterator, bool> ret;
|
||||||
ret = dirtyExpirationQueueRows.insert(std::pair<int, claimQueueRowType >(nHeight, newRow));
|
ret = dirtyExpirationQueueRows.insert(std::pair<int, expirationQueueRowType >(nHeight, newRow));
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
itQueueRow = ret.first;
|
itQueueRow = ret.first;
|
||||||
}
|
}
|
||||||
|
@ -591,28 +591,28 @@ void CClaimTrie::updateSupportQueue(int nHeight, supportQueueRowType& row)
|
||||||
itQueueRow->second.swap(row);
|
itQueueRow->second.swap(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClaimTrie::updateSupportNameQueue(const std::string& name, outPointHeightRowType& row)
|
void CClaimTrie::updateSupportNameQueue(const std::string& name, queueNameRowType& row)
|
||||||
{
|
{
|
||||||
nameOutPointHeightMapType::iterator itQueueRow = dirtySupportQueueNameRows.find(name);
|
queueNameType::iterator itQueueRow = dirtySupportQueueNameRows.find(name);
|
||||||
if (itQueueRow == dirtySupportQueueNameRows.end())
|
if (itQueueRow == dirtySupportQueueNameRows.end())
|
||||||
{
|
{
|
||||||
outPointHeightRowType newRow;
|
queueNameRowType newRow;
|
||||||
std::pair<nameOutPointHeightMapType::iterator, bool> ret;
|
std::pair<queueNameType::iterator, bool> ret;
|
||||||
ret = dirtySupportQueueNameRows.insert(std::pair<std::string, outPointHeightRowType>(name, newRow));
|
ret = dirtySupportQueueNameRows.insert(std::pair<std::string, queueNameRowType>(name, newRow));
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
itQueueRow = ret.first;
|
itQueueRow = ret.first;
|
||||||
}
|
}
|
||||||
itQueueRow->second.swap(row);
|
itQueueRow->second.swap(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClaimTrie::updateSupportExpirationQueue(int nHeight, supportQueueRowType& row)
|
void CClaimTrie::updateSupportExpirationQueue(int nHeight, expirationQueueRowType& row)
|
||||||
{
|
{
|
||||||
supportQueueType::iterator itQueueRow = dirtySupportExpirationQueueRows.find(nHeight);
|
expirationQueueType::iterator itQueueRow = dirtySupportExpirationQueueRows.find(nHeight);
|
||||||
if (itQueueRow == dirtySupportExpirationQueueRows.end())
|
if (itQueueRow == dirtySupportExpirationQueueRows.end())
|
||||||
{
|
{
|
||||||
supportQueueRowType newRow;
|
expirationQueueRowType newRow;
|
||||||
std::pair<supportQueueType::iterator, bool> ret;
|
std::pair<expirationQueueType::iterator, bool> ret;
|
||||||
ret = dirtySupportExpirationQueueRows.insert(std::pair<int, supportQueueRowType >(nHeight, newRow));
|
ret = dirtySupportExpirationQueueRows.insert(std::pair<int, expirationQueueRowType >(nHeight, newRow));
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
itQueueRow = ret.first;
|
itQueueRow = ret.first;
|
||||||
}
|
}
|
||||||
|
@ -641,9 +641,9 @@ bool CClaimTrie::getSupportQueueRow(int nHeight, supportQueueRowType& row) const
|
||||||
return db.Read(std::make_pair(SUPPORT_QUEUE_ROW, nHeight), row);
|
return db.Read(std::make_pair(SUPPORT_QUEUE_ROW, nHeight), row);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrie::getSupportQueueNameRow(const std::string& name, outPointHeightRowType& row) const
|
bool CClaimTrie::getSupportQueueNameRow(const std::string& name, queueNameRowType& row) const
|
||||||
{
|
{
|
||||||
nameOutPointHeightMapType::const_iterator itQueueNameRow = dirtySupportQueueNameRows.find(name);
|
queueNameType::const_iterator itQueueNameRow = dirtySupportQueueNameRows.find(name);
|
||||||
if (itQueueNameRow != dirtySupportQueueNameRows.end())
|
if (itQueueNameRow != dirtySupportQueueNameRows.end())
|
||||||
{
|
{
|
||||||
row = itQueueNameRow->second;
|
row = itQueueNameRow->second;
|
||||||
|
@ -652,9 +652,9 @@ bool CClaimTrie::getSupportQueueNameRow(const std::string& name, outPointHeightR
|
||||||
return db.Read(std::make_pair(SUPPORT_QUEUE_NAME_ROW, name), row);
|
return db.Read(std::make_pair(SUPPORT_QUEUE_NAME_ROW, name), row);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrie::getSupportExpirationQueueRow(int nHeight, supportQueueRowType& row) const
|
bool CClaimTrie::getSupportExpirationQueueRow(int nHeight, expirationQueueRowType& row) const
|
||||||
{
|
{
|
||||||
supportQueueType::const_iterator itQueueRow = dirtySupportExpirationQueueRows.find(nHeight);
|
expirationQueueType::const_iterator itQueueRow = dirtySupportExpirationQueueRows.find(nHeight);
|
||||||
if (itQueueRow != dirtySupportExpirationQueueRows.end())
|
if (itQueueRow != dirtySupportExpirationQueueRows.end())
|
||||||
{
|
{
|
||||||
row = itQueueRow->second;
|
row = itQueueRow->second;
|
||||||
|
@ -663,7 +663,7 @@ bool CClaimTrie::getSupportExpirationQueueRow(int nHeight, supportQueueRowType&
|
||||||
return db.Read(std::make_pair(SUPPORT_EXP_QUEUE_ROW, nHeight), row);
|
return db.Read(std::make_pair(SUPPORT_EXP_QUEUE_ROW, nHeight), row);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrie::update(nodeCacheType& cache, hashMapType& hashes, std::map<std::string, int>& takeoverHeights, const uint256& hashBlockIn, claimQueueType& queueCache, nameOutPointHeightMapType& queueNameCache, claimQueueType& expirationQueueCache, int nNewHeight, supportMapType& supportCache, supportQueueType& supportQueueCache, nameOutPointHeightMapType& supportQueueNameCache, supportQueueType& supportExpirationQueueCache)
|
bool CClaimTrie::update(nodeCacheType& cache, hashMapType& hashes, std::map<std::string, int>& takeoverHeights, const uint256& hashBlockIn, claimQueueType& queueCache, queueNameType& queueNameCache, expirationQueueType& expirationQueueCache, int nNewHeight, supportMapType& supportCache, supportQueueType& supportQueueCache, queueNameType& supportQueueNameCache, expirationQueueType& supportExpirationQueueCache)
|
||||||
{
|
{
|
||||||
for (nodeCacheType::iterator itcache = cache.begin(); itcache != cache.end(); ++itcache)
|
for (nodeCacheType::iterator itcache = cache.begin(); itcache != cache.end(); ++itcache)
|
||||||
{
|
{
|
||||||
|
@ -684,11 +684,11 @@ bool CClaimTrie::update(nodeCacheType& cache, hashMapType& hashes, std::map<std:
|
||||||
{
|
{
|
||||||
updateQueueRow(itQueueCacheRow->first, itQueueCacheRow->second);
|
updateQueueRow(itQueueCacheRow->first, itQueueCacheRow->second);
|
||||||
}
|
}
|
||||||
for (nameOutPointHeightMapType::iterator itQueueNameCacheRow = queueNameCache.begin(); itQueueNameCacheRow != queueNameCache.end(); ++itQueueNameCacheRow)
|
for (queueNameType::iterator itQueueNameCacheRow = queueNameCache.begin(); itQueueNameCacheRow != queueNameCache.end(); ++itQueueNameCacheRow)
|
||||||
{
|
{
|
||||||
updateQueueNameRow(itQueueNameCacheRow->first, itQueueNameCacheRow->second);
|
updateQueueNameRow(itQueueNameCacheRow->first, itQueueNameCacheRow->second);
|
||||||
}
|
}
|
||||||
for (claimQueueType::iterator itExpirationRow = expirationQueueCache.begin(); itExpirationRow != expirationQueueCache.end(); ++itExpirationRow)
|
for (expirationQueueType::iterator itExpirationRow = expirationQueueCache.begin(); itExpirationRow != expirationQueueCache.end(); ++itExpirationRow)
|
||||||
{
|
{
|
||||||
updateExpirationRow(itExpirationRow->first, itExpirationRow->second);
|
updateExpirationRow(itExpirationRow->first, itExpirationRow->second);
|
||||||
}
|
}
|
||||||
|
@ -700,11 +700,11 @@ bool CClaimTrie::update(nodeCacheType& cache, hashMapType& hashes, std::map<std:
|
||||||
{
|
{
|
||||||
updateSupportQueue(itSupportQueue->first, itSupportQueue->second);
|
updateSupportQueue(itSupportQueue->first, itSupportQueue->second);
|
||||||
}
|
}
|
||||||
for (nameOutPointHeightMapType::iterator itSupportNameQueue = supportQueueNameCache.begin(); itSupportNameQueue != supportQueueNameCache.end(); ++itSupportNameQueue)
|
for (queueNameType::iterator itSupportNameQueue = supportQueueNameCache.begin(); itSupportNameQueue != supportQueueNameCache.end(); ++itSupportNameQueue)
|
||||||
{
|
{
|
||||||
updateSupportNameQueue(itSupportNameQueue->first, itSupportNameQueue->second);
|
updateSupportNameQueue(itSupportNameQueue->first, itSupportNameQueue->second);
|
||||||
}
|
}
|
||||||
for (supportQueueType::iterator itSupportExpirationQueue = supportExpirationQueueCache.begin(); itSupportExpirationQueue != supportExpirationQueueCache.end(); ++itSupportExpirationQueue)
|
for (expirationQueueType::iterator itSupportExpirationQueue = supportExpirationQueueCache.begin(); itSupportExpirationQueue != supportExpirationQueueCache.end(); ++itSupportExpirationQueue)
|
||||||
{
|
{
|
||||||
updateSupportExpirationQueue(itSupportExpirationQueue->first, itSupportExpirationQueue->second);
|
updateSupportExpirationQueue(itSupportExpirationQueue->first, itSupportExpirationQueue->second);
|
||||||
}
|
}
|
||||||
|
@ -844,7 +844,7 @@ void CClaimTrie::BatchWriteQueueRows(CLevelDBBatch& batch)
|
||||||
|
|
||||||
void CClaimTrie::BatchWriteQueueNameRows(CLevelDBBatch& batch)
|
void CClaimTrie::BatchWriteQueueNameRows(CLevelDBBatch& batch)
|
||||||
{
|
{
|
||||||
for (nameOutPointHeightMapType::iterator itQueue = dirtyQueueNameRows.begin(); itQueue != dirtyQueueNameRows.end(); ++itQueue)
|
for (queueNameType::iterator itQueue = dirtyQueueNameRows.begin(); itQueue != dirtyQueueNameRows.end(); ++itQueue)
|
||||||
{
|
{
|
||||||
if (itQueue->second.empty())
|
if (itQueue->second.empty())
|
||||||
{
|
{
|
||||||
|
@ -859,7 +859,7 @@ void CClaimTrie::BatchWriteQueueNameRows(CLevelDBBatch& batch)
|
||||||
|
|
||||||
void CClaimTrie::BatchWriteExpirationQueueRows(CLevelDBBatch& batch)
|
void CClaimTrie::BatchWriteExpirationQueueRows(CLevelDBBatch& batch)
|
||||||
{
|
{
|
||||||
for (claimQueueType::iterator itQueue = dirtyExpirationQueueRows.begin(); itQueue != dirtyExpirationQueueRows.end(); ++itQueue)
|
for (expirationQueueType::iterator itQueue = dirtyExpirationQueueRows.begin(); itQueue != dirtyExpirationQueueRows.end(); ++itQueue)
|
||||||
{
|
{
|
||||||
if (itQueue->second.empty())
|
if (itQueue->second.empty())
|
||||||
{
|
{
|
||||||
|
@ -904,7 +904,7 @@ void CClaimTrie::BatchWriteSupportQueueRows(CLevelDBBatch& batch)
|
||||||
|
|
||||||
void CClaimTrie::BatchWriteSupportQueueNameRows(CLevelDBBatch& batch)
|
void CClaimTrie::BatchWriteSupportQueueNameRows(CLevelDBBatch& batch)
|
||||||
{
|
{
|
||||||
for (nameOutPointHeightMapType::iterator itQueue = dirtySupportQueueNameRows.begin(); itQueue != dirtySupportQueueNameRows.end(); ++itQueue)
|
for (queueNameType::iterator itQueue = dirtySupportQueueNameRows.begin(); itQueue != dirtySupportQueueNameRows.end(); ++itQueue)
|
||||||
{
|
{
|
||||||
if (itQueue->second.empty())
|
if (itQueue->second.empty())
|
||||||
{
|
{
|
||||||
|
@ -919,7 +919,7 @@ void CClaimTrie::BatchWriteSupportQueueNameRows(CLevelDBBatch& batch)
|
||||||
|
|
||||||
void CClaimTrie::BatchWriteSupportExpirationQueueRows(CLevelDBBatch& batch)
|
void CClaimTrie::BatchWriteSupportExpirationQueueRows(CLevelDBBatch& batch)
|
||||||
{
|
{
|
||||||
for (supportQueueType::iterator itQueue = dirtySupportExpirationQueueRows.begin(); itQueue != dirtySupportExpirationQueueRows.end(); ++itQueue)
|
for (expirationQueueType::iterator itQueue = dirtySupportExpirationQueueRows.begin(); itQueue != dirtySupportExpirationQueueRows.end(); ++itQueue)
|
||||||
{
|
{
|
||||||
if (itQueue->second.empty())
|
if (itQueue->second.empty())
|
||||||
{
|
{
|
||||||
|
@ -950,6 +950,8 @@ bool CClaimTrie::WriteToDisk()
|
||||||
dirtySupportQueueRows.clear();
|
dirtySupportQueueRows.clear();
|
||||||
BatchWriteSupportQueueNameRows(batch);
|
BatchWriteSupportQueueNameRows(batch);
|
||||||
dirtySupportQueueNameRows.clear();
|
dirtySupportQueueNameRows.clear();
|
||||||
|
BatchWriteSupportExpirationQueueRows(batch);
|
||||||
|
dirtySupportExpirationQueueRows.clear();
|
||||||
batch.Write(HASH_BLOCK, hashBlock);
|
batch.Write(HASH_BLOCK, hashBlock);
|
||||||
batch.Write(CURRENT_HEIGHT, nCurrentHeight);
|
batch.Write(CURRENT_HEIGHT, nCurrentHeight);
|
||||||
return db.WriteBatch(batch);
|
return db.WriteBatch(batch);
|
||||||
|
@ -1383,21 +1385,21 @@ claimQueueType::iterator CClaimTrieCache::getQueueCacheRow(int nHeight, bool cre
|
||||||
return itQueueRow;
|
return itQueueRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
nameOutPointHeightMapType::iterator CClaimTrieCache::getQueueCacheNameRow(const std::string& name, bool createIfNotExists) const
|
queueNameType::iterator CClaimTrieCache::getQueueCacheNameRow(const std::string& name, bool createIfNotExists) const
|
||||||
{
|
{
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = claimQueueNameCache.find(name);
|
queueNameType::iterator itQueueNameRow = claimQueueNameCache.find(name);
|
||||||
if (itQueueNameRow == claimQueueNameCache.end())
|
if (itQueueNameRow == claimQueueNameCache.end())
|
||||||
{
|
{
|
||||||
// Have to make a new name row and put it in the cache, if createIfNotExists is true
|
// Have to make a new name row and put it in the cache, if createIfNotExists is true
|
||||||
outPointHeightRowType queueNameRow;
|
queueNameRowType queueNameRow;
|
||||||
// If the row exists in the base, copy its claims into the new row.
|
// If the row exists in the base, copy its claims into the new row.
|
||||||
bool exists = base->getQueueNameRow(name, queueNameRow);
|
bool exists = base->getQueueNameRow(name, queueNameRow);
|
||||||
if (!exists)
|
if (!exists)
|
||||||
if (!createIfNotExists)
|
if (!createIfNotExists)
|
||||||
return itQueueNameRow;
|
return itQueueNameRow;
|
||||||
// Stick the new row in the cache
|
// Stick the new row in the cache
|
||||||
std::pair<nameOutPointHeightMapType::iterator, bool> ret;
|
std::pair<queueNameType::iterator, bool> ret;
|
||||||
ret = claimQueueNameCache.insert(std::pair<std::string, outPointHeightRowType>(name, queueNameRow));
|
ret = claimQueueNameCache.insert(std::pair<std::string, queueNameRowType>(name, queueNameRow));
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
itQueueNameRow = ret.first;
|
itQueueNameRow = ret.first;
|
||||||
}
|
}
|
||||||
|
@ -1429,8 +1431,8 @@ bool CClaimTrieCache::undoSpendClaim(const std::string& name, const COutPoint& o
|
||||||
CClaimValue claim(outPoint, claimId, nAmount, nHeight, nValidAtHeight);
|
CClaimValue claim(outPoint, claimId, nAmount, nHeight, nValidAtHeight);
|
||||||
if (nValidAtHeight < nCurrentHeight)
|
if (nValidAtHeight < nCurrentHeight)
|
||||||
{
|
{
|
||||||
claimQueueEntryType entry(name, claim);
|
nameOutPointType entry(name, claim.outPoint);
|
||||||
addToExpirationQueue(entry);
|
addToExpirationQueue(claim.nHeight + base->nExpirationTime, entry);
|
||||||
return insertClaimIntoTrie(name, claim, false);
|
return insertClaimIntoTrie(name, claim, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1444,21 +1446,22 @@ bool CClaimTrieCache::addClaimToQueues(const std::string& name, CClaimValue& cla
|
||||||
LogPrintf("%s: nValidAtHeight: %d\n", __func__, claim.nValidAtHeight);
|
LogPrintf("%s: nValidAtHeight: %d\n", __func__, claim.nValidAtHeight);
|
||||||
claimQueueEntryType entry(name, claim);
|
claimQueueEntryType entry(name, claim);
|
||||||
claimQueueType::iterator itQueueRow = getQueueCacheRow(claim.nValidAtHeight, true);
|
claimQueueType::iterator itQueueRow = getQueueCacheRow(claim.nValidAtHeight, true);
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = getQueueCacheNameRow(name, true);
|
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(name, true);
|
||||||
itQueueRow->second.push_back(entry);
|
itQueueRow->second.push_back(entry);
|
||||||
itQueueNameRow->second.push_back(outPointHeightType(claim.outPoint, claim.nValidAtHeight));
|
itQueueNameRow->second.push_back(outPointHeightType(claim.outPoint, claim.nValidAtHeight));
|
||||||
addToExpirationQueue(entry);
|
nameOutPointType expireEntry(name, claim.outPoint);
|
||||||
|
addToExpirationQueue(claim.nHeight + base->nExpirationTime, expireEntry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrieCache::removeClaimFromQueue(const std::string& name, const COutPoint& outPoint, CClaimValue& claim) const
|
bool CClaimTrieCache::removeClaimFromQueue(const std::string& name, const COutPoint& outPoint, CClaimValue& claim) const
|
||||||
{
|
{
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = getQueueCacheNameRow(name, false);
|
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(name, false);
|
||||||
if (itQueueNameRow == claimQueueNameCache.end())
|
if (itQueueNameRow == claimQueueNameCache.end())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
outPointHeightRowType::iterator itQueueName;
|
queueNameRowType::iterator itQueueName;
|
||||||
for (itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
for (itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
||||||
{
|
{
|
||||||
if (itQueueName->outPoint == outPoint)
|
if (itQueueName->outPoint == outPoint)
|
||||||
|
@ -1525,24 +1528,22 @@ bool CClaimTrieCache::removeClaim(const std::string& name, const COutPoint& outP
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClaimTrieCache::addToExpirationQueue(claimQueueEntryType& entry) const
|
void CClaimTrieCache::addToExpirationQueue(int nExpirationHeight, nameOutPointType& entry) const
|
||||||
{
|
{
|
||||||
int expirationHeight = entry.second.nHeight + base->nExpirationTime;
|
expirationQueueType::iterator itQueueRow = getExpirationQueueCacheRow(nExpirationHeight, true);
|
||||||
claimQueueType::iterator itQueueRow = getExpirationQueueCacheRow(expirationHeight, true);
|
|
||||||
itQueueRow->second.push_back(entry);
|
itQueueRow->second.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClaimTrieCache::removeFromExpirationQueue(const std::string& name, const COutPoint& outPoint, int nHeight) const
|
void CClaimTrieCache::removeFromExpirationQueue(const std::string& name, const COutPoint& outPoint, int nHeight) const
|
||||||
{
|
{
|
||||||
int expirationHeight = nHeight + base->nExpirationTime;
|
int expirationHeight = nHeight + base->nExpirationTime;
|
||||||
claimQueueType::iterator itQueueRow = getExpirationQueueCacheRow(expirationHeight, false);
|
expirationQueueType::iterator itQueueRow = getExpirationQueueCacheRow(expirationHeight, false);
|
||||||
claimQueueRowType::iterator itQueue;
|
expirationQueueRowType::iterator itQueue;
|
||||||
if (itQueueRow != claimQueueCache.end())
|
if (itQueueRow != expirationQueueCache.end())
|
||||||
{
|
{
|
||||||
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
|
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
|
||||||
{
|
{
|
||||||
CClaimValue& claim = itQueue->second;
|
if (name == itQueue->name && outPoint == itQueue->outPoint)
|
||||||
if (name == itQueue->first && claim.outPoint == outPoint)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1552,21 +1553,21 @@ void CClaimTrieCache::removeFromExpirationQueue(const std::string& name, const C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
claimQueueType::iterator CClaimTrieCache::getExpirationQueueCacheRow(int nHeight, bool createIfNotExists) const
|
expirationQueueType::iterator CClaimTrieCache::getExpirationQueueCacheRow(int nHeight, bool createIfNotExists) const
|
||||||
{
|
{
|
||||||
claimQueueType::iterator itQueueRow = expirationQueueCache.find(nHeight);
|
expirationQueueType::iterator itQueueRow = expirationQueueCache.find(nHeight);
|
||||||
if (itQueueRow == expirationQueueCache.end())
|
if (itQueueRow == expirationQueueCache.end())
|
||||||
{
|
{
|
||||||
// Have to make a new row it put in the cache, if createIfNotExists is true
|
// Have to make a new row it put in the cache, if createIfNotExists is true
|
||||||
claimQueueRowType queueRow;
|
expirationQueueRowType queueRow;
|
||||||
// If the row exists in the base, copy its claims into the new row.
|
// If the row exists in the base, copy its claims into the new row.
|
||||||
bool exists = base->getExpirationQueueRow(nHeight, queueRow);
|
bool exists = base->getExpirationQueueRow(nHeight, queueRow);
|
||||||
if (!exists)
|
if (!exists)
|
||||||
if (!createIfNotExists)
|
if (!createIfNotExists)
|
||||||
return itQueueRow;
|
return itQueueRow;
|
||||||
// Stick the new row in the cache
|
// Stick the new row in the cache
|
||||||
std::pair<claimQueueType::iterator, bool> ret;
|
std::pair<expirationQueueType::iterator, bool> ret;
|
||||||
ret = expirationQueueCache.insert(std::pair<int, claimQueueRowType >(nHeight, queueRow));
|
ret = expirationQueueCache.insert(std::pair<int, expirationQueueRowType >(nHeight, queueRow));
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
itQueueRow = ret.first;
|
itQueueRow = ret.first;
|
||||||
}
|
}
|
||||||
|
@ -1728,19 +1729,19 @@ supportQueueType::iterator CClaimTrieCache::getSupportQueueCacheRow(int nHeight,
|
||||||
return itQueueRow;
|
return itQueueRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
nameOutPointHeightMapType::iterator CClaimTrieCache::getSupportQueueCacheNameRow(const std::string& name, bool createIfNotExists) const
|
queueNameType::iterator CClaimTrieCache::getSupportQueueCacheNameRow(const std::string& name, bool createIfNotExists) const
|
||||||
{
|
{
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = supportQueueNameCache.find(name);
|
queueNameType::iterator itQueueNameRow = supportQueueNameCache.find(name);
|
||||||
if (itQueueNameRow == supportQueueNameCache.end())
|
if (itQueueNameRow == supportQueueNameCache.end())
|
||||||
{
|
{
|
||||||
outPointHeightRowType queueNameRow;
|
queueNameRowType queueNameRow;
|
||||||
bool exists = base->getSupportQueueNameRow(name, queueNameRow);
|
bool exists = base->getSupportQueueNameRow(name, queueNameRow);
|
||||||
if (!exists)
|
if (!exists)
|
||||||
if (!createIfNotExists)
|
if (!createIfNotExists)
|
||||||
return itQueueNameRow;
|
return itQueueNameRow;
|
||||||
// Stick the new row in the name cache
|
// Stick the new row in the name cache
|
||||||
std::pair<nameOutPointHeightMapType::iterator, bool> ret;
|
std::pair<queueNameType::iterator, bool> ret;
|
||||||
ret = supportQueueNameCache.insert(std::pair<std::string, outPointHeightRowType>(name, queueNameRow));
|
ret = supportQueueNameCache.insert(std::pair<std::string, queueNameRowType>(name, queueNameRow));
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
itQueueNameRow = ret.first;
|
itQueueNameRow = ret.first;
|
||||||
}
|
}
|
||||||
|
@ -1752,21 +1753,22 @@ bool CClaimTrieCache::addSupportToQueues(const std::string& name, CSupportValue&
|
||||||
LogPrintf("%s: nValidAtHeight: %d\n", __func__, support.nValidAtHeight);
|
LogPrintf("%s: nValidAtHeight: %d\n", __func__, support.nValidAtHeight);
|
||||||
supportQueueEntryType entry(name, support);
|
supportQueueEntryType entry(name, support);
|
||||||
supportQueueType::iterator itQueueRow = getSupportQueueCacheRow(support.nValidAtHeight, true);
|
supportQueueType::iterator itQueueRow = getSupportQueueCacheRow(support.nValidAtHeight, true);
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = getSupportQueueCacheNameRow(name, true);
|
queueNameType::iterator itQueueNameRow = getSupportQueueCacheNameRow(name, true);
|
||||||
itQueueRow->second.push_back(entry);
|
itQueueRow->second.push_back(entry);
|
||||||
itQueueNameRow->second.push_back(outPointHeightType(support.outPoint, support.nValidAtHeight));
|
itQueueNameRow->second.push_back(outPointHeightType(support.outPoint, support.nValidAtHeight));
|
||||||
addSupportToExpirationQueue(entry);
|
nameOutPointType expireEntry(name, support.outPoint);
|
||||||
|
addSupportToExpirationQueue(support.nHeight + base->nExpirationTime, expireEntry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrieCache::removeSupportFromQueue(const std::string& name, const COutPoint& outPoint, CSupportValue& support) const
|
bool CClaimTrieCache::removeSupportFromQueue(const std::string& name, const COutPoint& outPoint, CSupportValue& support) const
|
||||||
{
|
{
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = getSupportQueueCacheNameRow(name, false);
|
queueNameType::iterator itQueueNameRow = getSupportQueueCacheNameRow(name, false);
|
||||||
if (itQueueNameRow == supportQueueNameCache.end())
|
if (itQueueNameRow == supportQueueNameCache.end())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
outPointHeightRowType::iterator itQueueName;
|
queueNameRowType::iterator itQueueName;
|
||||||
for (itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
for (itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
||||||
{
|
{
|
||||||
if (itQueueName->outPoint == outPoint)
|
if (itQueueName->outPoint == outPoint)
|
||||||
|
@ -1827,8 +1829,8 @@ bool CClaimTrieCache::undoSpendSupport(const std::string& name, const COutPoint&
|
||||||
CSupportValue support(outPoint, supportedClaimId, nAmount, nHeight, nValidAtHeight);
|
CSupportValue support(outPoint, supportedClaimId, nAmount, nHeight, nValidAtHeight);
|
||||||
if (nValidAtHeight < nCurrentHeight)
|
if (nValidAtHeight < nCurrentHeight)
|
||||||
{
|
{
|
||||||
supportQueueEntryType entry(name, support);
|
nameOutPointType entry(name, support.outPoint);
|
||||||
addSupportToExpirationQueue(entry);
|
addSupportToExpirationQueue(support.nHeight + base->nExpirationTime, entry);
|
||||||
return insertSupportIntoMap(name, support, false);
|
return insertSupportIntoMap(name, support, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1853,24 +1855,22 @@ bool CClaimTrieCache::removeSupport(const std::string& name, const COutPoint& ou
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClaimTrieCache::addSupportToExpirationQueue(supportQueueEntryType& entry) const
|
void CClaimTrieCache::addSupportToExpirationQueue(int nExpirationHeight, nameOutPointType& entry) const
|
||||||
{
|
{
|
||||||
int expirationHeight = entry.second.nHeight + base->nExpirationTime;
|
expirationQueueType::iterator itQueueRow = getSupportExpirationQueueCacheRow(nExpirationHeight, true);
|
||||||
supportQueueType::iterator itQueueRow = getSupportExpirationQueueCacheRow(expirationHeight, true);
|
|
||||||
itQueueRow->second.push_back(entry);
|
itQueueRow->second.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClaimTrieCache::removeSupportFromExpirationQueue(const std::string& name, const COutPoint& outPoint, int nHeight) const
|
void CClaimTrieCache::removeSupportFromExpirationQueue(const std::string& name, const COutPoint& outPoint, int nHeight) const
|
||||||
{
|
{
|
||||||
int expirationHeight = nHeight + base->nExpirationTime;
|
int expirationHeight = nHeight + base->nExpirationTime;
|
||||||
supportQueueType::iterator itQueueRow = getSupportExpirationQueueCacheRow(expirationHeight, false);
|
expirationQueueType::iterator itQueueRow = getSupportExpirationQueueCacheRow(expirationHeight, false);
|
||||||
supportQueueRowType::iterator itQueue;
|
expirationQueueRowType::iterator itQueue;
|
||||||
if (itQueueRow != supportExpirationQueueCache.end())
|
if (itQueueRow != supportExpirationQueueCache.end())
|
||||||
{
|
{
|
||||||
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
|
for (itQueue = itQueueRow->second.begin(); itQueue != itQueueRow->second.end(); ++itQueue)
|
||||||
{
|
{
|
||||||
CSupportValue& support = itQueue->second;
|
if (name == itQueue->name && outPoint == itQueue->outPoint)
|
||||||
if (name == itQueue->first && support.outPoint == outPoint)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1880,21 +1880,21 @@ void CClaimTrieCache::removeSupportFromExpirationQueue(const std::string& name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
supportQueueType::iterator CClaimTrieCache::getSupportExpirationQueueCacheRow(int nHeight, bool createIfNotExists) const
|
expirationQueueType::iterator CClaimTrieCache::getSupportExpirationQueueCacheRow(int nHeight, bool createIfNotExists) const
|
||||||
{
|
{
|
||||||
supportQueueType::iterator itQueueRow = supportExpirationQueueCache.find(nHeight);
|
expirationQueueType::iterator itQueueRow = supportExpirationQueueCache.find(nHeight);
|
||||||
if (itQueueRow == supportExpirationQueueCache.end())
|
if (itQueueRow == supportExpirationQueueCache.end())
|
||||||
{
|
{
|
||||||
// Have to make a new row it put in the cache, if createIfNotExists is true
|
// Have to make a new row it put in the cache, if createIfNotExists is true
|
||||||
supportQueueRowType queueRow;
|
expirationQueueRowType queueRow;
|
||||||
// If the row exists in the base, copy its claims into the new row.
|
// If the row exists in the base, copy its claims into the new row.
|
||||||
bool exists = base->getSupportExpirationQueueRow(nHeight, queueRow);
|
bool exists = base->getSupportExpirationQueueRow(nHeight, queueRow);
|
||||||
if (!exists)
|
if (!exists)
|
||||||
if (!createIfNotExists)
|
if (!createIfNotExists)
|
||||||
return itQueueRow;
|
return itQueueRow;
|
||||||
// Stick the new row in the cache
|
// Stick the new row in the cache
|
||||||
std::pair<supportQueueType::iterator, bool> ret;
|
std::pair<expirationQueueType::iterator, bool> ret;
|
||||||
ret = supportExpirationQueueCache.insert(std::pair<int, supportQueueRowType >(nHeight, queueRow));
|
ret = supportExpirationQueueCache.insert(std::pair<int, expirationQueueRowType >(nHeight, queueRow));
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
itQueueRow = ret.first;
|
itQueueRow = ret.first;
|
||||||
}
|
}
|
||||||
|
@ -1914,7 +1914,7 @@ bool CClaimTrieCache::spendSupport(const std::string& name, const COutPoint& out
|
||||||
return removeSupport(name, outPoint, nHeight, nValidAtHeight, true);
|
return removeSupport(name, outPoint, nHeight, nValidAtHeight, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, claimQueueRowType& expireUndo, nameOutPointHeightRowType& insertSupportUndo, supportQueueRowType& expireSupportUndo, std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const
|
bool CClaimTrieCache::incrementBlock(insertUndoType& insertUndo, claimQueueRowType& expireUndo, insertUndoType& insertSupportUndo, supportQueueRowType& expireSupportUndo, std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const
|
||||||
{
|
{
|
||||||
LogPrintf("%s: nCurrentHeight (before increment): %d\n", __func__, nCurrentHeight);
|
LogPrintf("%s: nCurrentHeight (before increment): %d\n", __func__, nCurrentHeight);
|
||||||
claimQueueType::iterator itQueueRow = getQueueCacheRow(nCurrentHeight, false);
|
claimQueueType::iterator itQueueRow = getQueueCacheRow(nCurrentHeight, false);
|
||||||
|
@ -1923,10 +1923,10 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
for (claimQueueRowType::iterator itEntry = itQueueRow->second.begin(); itEntry != itQueueRow->second.end(); ++itEntry)
|
for (claimQueueRowType::iterator itEntry = itQueueRow->second.begin(); itEntry != itQueueRow->second.end(); ++itEntry)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = getQueueCacheNameRow(itEntry->first, false);
|
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(itEntry->first, false);
|
||||||
if (itQueueNameRow != claimQueueNameCache.end())
|
if (itQueueNameRow != claimQueueNameCache.end())
|
||||||
{
|
{
|
||||||
for (outPointHeightRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
for (queueNameRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
||||||
{
|
{
|
||||||
if (itQueueName->outPoint == itEntry->second.outPoint && itQueueName->nHeight == nCurrentHeight)
|
if (itQueueName->outPoint == itEntry->second.outPoint && itQueueName->nHeight == nCurrentHeight)
|
||||||
{
|
{
|
||||||
|
@ -1942,7 +1942,7 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
if (itQueueNameRow != claimQueueNameCache.end())
|
if (itQueueNameRow != claimQueueNameCache.end())
|
||||||
{
|
{
|
||||||
LogPrintf("Claims found for that name:\n");
|
LogPrintf("Claims found for that name:\n");
|
||||||
for (outPointHeightRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
for (queueNameRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
||||||
{
|
{
|
||||||
LogPrintf("\ttxid: %s, nOut: %d, nValidAtHeight: %d\n", itQueueName->outPoint.hash.GetHex(), itQueueName->outPoint.n, itQueueName->nHeight);
|
LogPrintf("\ttxid: %s, nOut: %d, nValidAtHeight: %d\n", itQueueName->outPoint.hash.GetHex(), itQueueName->outPoint.n, itQueueName->nHeight);
|
||||||
}
|
}
|
||||||
|
@ -1958,14 +1958,14 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
}
|
}
|
||||||
itQueueRow->second.clear();
|
itQueueRow->second.clear();
|
||||||
}
|
}
|
||||||
claimQueueType::iterator itExpirationRow = getExpirationQueueCacheRow(nCurrentHeight, false);
|
expirationQueueType::iterator itExpirationRow = getExpirationQueueCacheRow(nCurrentHeight, false);
|
||||||
if (itExpirationRow != expirationQueueCache.end())
|
if (itExpirationRow != expirationQueueCache.end())
|
||||||
{
|
{
|
||||||
for (claimQueueRowType::iterator itEntry = itExpirationRow->second.begin(); itEntry != itExpirationRow->second.end(); ++itEntry)
|
for (expirationQueueRowType::iterator itEntry = itExpirationRow->second.begin(); itEntry != itExpirationRow->second.end(); ++itEntry)
|
||||||
{
|
{
|
||||||
CClaimValue claim;
|
CClaimValue claim;
|
||||||
assert(removeClaimFromTrie(itEntry->first, itEntry->second.outPoint, claim, true));
|
assert(removeClaimFromTrie(itEntry->name, itEntry->outPoint, claim, true));
|
||||||
expireUndo.push_back(std::make_pair(itEntry->first, claim));
|
expireUndo.push_back(std::make_pair(itEntry->name, claim));
|
||||||
}
|
}
|
||||||
itExpirationRow->second.clear();
|
itExpirationRow->second.clear();
|
||||||
}
|
}
|
||||||
|
@ -1975,10 +1975,10 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
for (supportQueueRowType::iterator itSupport = itSupportRow->second.begin(); itSupport != itSupportRow->second.end(); ++itSupport)
|
for (supportQueueRowType::iterator itSupport = itSupportRow->second.begin(); itSupport != itSupportRow->second.end(); ++itSupport)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
nameOutPointHeightMapType::iterator itSupportNameRow = getSupportQueueCacheNameRow(itSupport->first, false);
|
queueNameType::iterator itSupportNameRow = getSupportQueueCacheNameRow(itSupport->first, false);
|
||||||
if (itSupportNameRow != supportQueueNameCache.end())
|
if (itSupportNameRow != supportQueueNameCache.end())
|
||||||
{
|
{
|
||||||
for (outPointHeightRowType::iterator itSupportName = itSupportNameRow->second.begin(); itSupportName != itSupportNameRow->second.end(); ++itSupportName)
|
for (queueNameRowType::iterator itSupportName = itSupportNameRow->second.begin(); itSupportName != itSupportNameRow->second.end(); ++itSupportName)
|
||||||
{
|
{
|
||||||
if (itSupportName->outPoint == itSupport->second.outPoint && itSupportName->nHeight == itSupport->second.nValidAtHeight)
|
if (itSupportName->outPoint == itSupport->second.outPoint && itSupportName->nHeight == itSupport->second.nValidAtHeight)
|
||||||
{
|
{
|
||||||
|
@ -1994,7 +1994,7 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
if (itSupportNameRow != supportQueueNameCache.end())
|
if (itSupportNameRow != supportQueueNameCache.end())
|
||||||
{
|
{
|
||||||
LogPrintf("Supports found for that name:\n");
|
LogPrintf("Supports found for that name:\n");
|
||||||
for (outPointHeightRowType::iterator itSupportName = itSupportNameRow->second.begin(); itSupportName != itSupportNameRow->second.end(); ++itSupportName)
|
for (queueNameRowType::iterator itSupportName = itSupportNameRow->second.begin(); itSupportName != itSupportNameRow->second.end(); ++itSupportName)
|
||||||
{
|
{
|
||||||
LogPrintf("\ttxid: %s, nOut: %d, nValidAtHeight: %d\n", itSupportName->outPoint.hash.GetHex(), itSupportName->outPoint.n, itSupportName->nHeight);
|
LogPrintf("\ttxid: %s, nOut: %d, nValidAtHeight: %d\n", itSupportName->outPoint.hash.GetHex(), itSupportName->outPoint.n, itSupportName->nHeight);
|
||||||
}
|
}
|
||||||
|
@ -2009,14 +2009,14 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
}
|
}
|
||||||
itSupportRow->second.clear();
|
itSupportRow->second.clear();
|
||||||
}
|
}
|
||||||
supportQueueType::iterator itSupportExpirationRow = getSupportExpirationQueueCacheRow(nCurrentHeight, false);
|
expirationQueueType::iterator itSupportExpirationRow = getSupportExpirationQueueCacheRow(nCurrentHeight, false);
|
||||||
if (itSupportExpirationRow != supportExpirationQueueCache.end())
|
if (itSupportExpirationRow != supportExpirationQueueCache.end())
|
||||||
{
|
{
|
||||||
for (supportQueueRowType::iterator itEntry = itSupportExpirationRow->second.begin(); itEntry != itSupportExpirationRow->second.end(); ++itEntry)
|
for (expirationQueueRowType::iterator itEntry = itSupportExpirationRow->second.begin(); itEntry != itSupportExpirationRow->second.end(); ++itEntry)
|
||||||
{
|
{
|
||||||
CSupportValue support;
|
CSupportValue support;
|
||||||
assert(removeSupportFromMap(itEntry->first, itEntry->second.outPoint, support, true));
|
assert(removeSupportFromMap(itEntry->name, itEntry->outPoint, support, true));
|
||||||
expireSupportUndo.push_back(std::make_pair(itEntry->first, support));
|
expireSupportUndo.push_back(std::make_pair(itEntry->name, support));
|
||||||
}
|
}
|
||||||
itSupportExpirationRow->second.clear();
|
itSupportExpirationRow->second.clear();
|
||||||
}
|
}
|
||||||
|
@ -2073,10 +2073,10 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
if (takeoverHappened)
|
if (takeoverHappened)
|
||||||
{
|
{
|
||||||
// Get all claims in the queue for that name
|
// Get all claims in the queue for that name
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = getQueueCacheNameRow(*itNamesToCheck, false);
|
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(*itNamesToCheck, false);
|
||||||
if (itQueueNameRow != claimQueueNameCache.end())
|
if (itQueueNameRow != claimQueueNameCache.end())
|
||||||
{
|
{
|
||||||
for (outPointHeightRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
for (queueNameRowType::iterator itQueueName = itQueueNameRow->second.begin(); itQueueName != itQueueNameRow->second.end(); ++itQueueName)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
// Pull those claims out of the height-based queue
|
// Pull those claims out of the height-based queue
|
||||||
|
@ -2114,10 +2114,10 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Then, get all supports in the queue for that name
|
// Then, get all supports in the queue for that name
|
||||||
nameOutPointHeightMapType::iterator itSupportQueueNameRow = getSupportQueueCacheNameRow(*itNamesToCheck, false);
|
queueNameType::iterator itSupportQueueNameRow = getSupportQueueCacheNameRow(*itNamesToCheck, false);
|
||||||
if (itSupportQueueNameRow != supportQueueNameCache.end())
|
if (itSupportQueueNameRow != supportQueueNameCache.end())
|
||||||
{
|
{
|
||||||
for (outPointHeightRowType::iterator itSupportQueueName = itSupportQueueNameRow->second.begin(); itSupportQueueName != itSupportQueueNameRow->second.end(); ++itSupportQueueName)
|
for (queueNameRowType::iterator itSupportQueueName = itSupportQueueNameRow->second.begin(); itSupportQueueName != itSupportQueueNameRow->second.end(); ++itSupportQueueName)
|
||||||
{
|
{
|
||||||
// Pull those supports out of the height-based queue
|
// Pull those supports out of the height-based queue
|
||||||
supportQueueType::iterator itSupportQueueRow = getSupportQueueCacheRow(itSupportQueueName->nHeight, false);
|
supportQueueType::iterator itSupportQueueRow = getSupportQueueCacheRow(itSupportQueueName->nHeight, false);
|
||||||
|
@ -2174,47 +2174,47 @@ bool CClaimTrieCache::incrementBlock(nameOutPointHeightRowType& insertUndo, clai
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClaimTrieCache::decrementBlock(nameOutPointHeightRowType& insertUndo, claimQueueRowType& expireUndo, nameOutPointHeightRowType& insertSupportUndo, supportQueueRowType& expireSupportUndo, std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const
|
bool CClaimTrieCache::decrementBlock(insertUndoType& insertUndo, claimQueueRowType& expireUndo, insertUndoType& insertSupportUndo, supportQueueRowType& expireSupportUndo, std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const
|
||||||
{
|
{
|
||||||
LogPrintf("%s: nCurrentHeight (before decrement): %d\n", __func__, nCurrentHeight);
|
LogPrintf("%s: nCurrentHeight (before decrement): %d\n", __func__, nCurrentHeight);
|
||||||
nCurrentHeight--;
|
nCurrentHeight--;
|
||||||
|
|
||||||
if (expireSupportUndo.begin() != expireSupportUndo.end())
|
if (expireSupportUndo.begin() != expireSupportUndo.end())
|
||||||
{
|
{
|
||||||
supportQueueType::iterator itSupportExpireRow = getSupportExpirationQueueCacheRow(nCurrentHeight, true);
|
expirationQueueType::iterator itSupportExpireRow = getSupportExpirationQueueCacheRow(nCurrentHeight, true);
|
||||||
for (supportQueueRowType::iterator itSupportExpireUndo = expireSupportUndo.begin(); itSupportExpireUndo != expireSupportUndo.end(); ++itSupportExpireUndo)
|
for (supportQueueRowType::iterator itSupportExpireUndo = expireSupportUndo.begin(); itSupportExpireUndo != expireSupportUndo.end(); ++itSupportExpireUndo)
|
||||||
{
|
{
|
||||||
insertSupportIntoMap(itSupportExpireUndo->first, itSupportExpireUndo->second, false);
|
insertSupportIntoMap(itSupportExpireUndo->first, itSupportExpireUndo->second, false);
|
||||||
itSupportExpireRow->second.push_back(*itSupportExpireUndo);
|
itSupportExpireRow->second.push_back(nameOutPointType(itSupportExpireUndo->first, itSupportExpireUndo->second.outPoint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (nameOutPointHeightRowType::iterator itSupportUndo = insertSupportUndo.begin(); itSupportUndo != insertSupportUndo.end(); ++itSupportUndo)
|
for (insertUndoType::iterator itSupportUndo = insertSupportUndo.begin(); itSupportUndo != insertSupportUndo.end(); ++itSupportUndo)
|
||||||
{
|
{
|
||||||
supportQueueType::iterator itSupportRow = getSupportQueueCacheRow(itSupportUndo->nHeight, true);
|
supportQueueType::iterator itSupportRow = getSupportQueueCacheRow(itSupportUndo->nHeight, true);
|
||||||
CSupportValue support;
|
CSupportValue support;
|
||||||
assert(removeSupportFromMap(itSupportUndo->name, itSupportUndo->outPoint, support, false));
|
assert(removeSupportFromMap(itSupportUndo->name, itSupportUndo->outPoint, support, false));
|
||||||
nameOutPointHeightMapType::iterator itSupportNameRow = getSupportQueueCacheNameRow(itSupportUndo->name, true);
|
queueNameType::iterator itSupportNameRow = getSupportQueueCacheNameRow(itSupportUndo->name, true);
|
||||||
itSupportRow->second.push_back(std::make_pair(itSupportUndo->name, support));
|
itSupportRow->second.push_back(std::make_pair(itSupportUndo->name, support));
|
||||||
itSupportNameRow->second.push_back(outPointHeightType(support.outPoint, support.nValidAtHeight));
|
itSupportNameRow->second.push_back(outPointHeightType(support.outPoint, support.nValidAtHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expireUndo.begin() != expireUndo.end())
|
if (expireUndo.begin() != expireUndo.end())
|
||||||
{
|
{
|
||||||
claimQueueType::iterator itExpireRow = getExpirationQueueCacheRow(nCurrentHeight, true);
|
expirationQueueType::iterator itExpireRow = getExpirationQueueCacheRow(nCurrentHeight, true);
|
||||||
for (claimQueueRowType::iterator itExpireUndo = expireUndo.begin(); itExpireUndo != expireUndo.end(); ++itExpireUndo)
|
for (claimQueueRowType::iterator itExpireUndo = expireUndo.begin(); itExpireUndo != expireUndo.end(); ++itExpireUndo)
|
||||||
{
|
{
|
||||||
insertClaimIntoTrie(itExpireUndo->first, itExpireUndo->second, false);
|
insertClaimIntoTrie(itExpireUndo->first, itExpireUndo->second, false);
|
||||||
itExpireRow->second.push_back(*itExpireUndo);
|
itExpireRow->second.push_back(nameOutPointType(itExpireUndo->first, itExpireUndo->second.outPoint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (nameOutPointHeightRowType::iterator itInsertUndo = insertUndo.begin(); itInsertUndo != insertUndo.end(); ++itInsertUndo)
|
for (insertUndoType::iterator itInsertUndo = insertUndo.begin(); itInsertUndo != insertUndo.end(); ++itInsertUndo)
|
||||||
{
|
{
|
||||||
claimQueueType::iterator itQueueRow = getQueueCacheRow(itInsertUndo->nHeight, true);
|
claimQueueType::iterator itQueueRow = getQueueCacheRow(itInsertUndo->nHeight, true);
|
||||||
CClaimValue claim;
|
CClaimValue claim;
|
||||||
assert(removeClaimFromTrie(itInsertUndo->name, itInsertUndo->outPoint, claim, false));
|
assert(removeClaimFromTrie(itInsertUndo->name, itInsertUndo->outPoint, claim, false));
|
||||||
nameOutPointHeightMapType::iterator itQueueNameRow = getQueueCacheNameRow(itInsertUndo->name, true);
|
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(itInsertUndo->name, true);
|
||||||
itQueueRow->second.push_back(std::make_pair(itInsertUndo->name, claim));
|
itQueueRow->second.push_back(std::make_pair(itInsertUndo->name, claim));
|
||||||
itQueueNameRow->second.push_back(outPointHeightType(itInsertUndo->outPoint, itInsertUndo->nHeight));
|
itQueueNameRow->second.push_back(outPointHeightType(itInsertUndo->outPoint, itInsertUndo->nHeight));
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,16 +221,39 @@ struct nameOutPointHeightType
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct nameOutPointType
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
COutPoint outPoint;
|
||||||
|
|
||||||
|
nameOutPointType() {}
|
||||||
|
|
||||||
|
nameOutPointType(std::string name, COutPoint outPoint)
|
||||||
|
: name(name), outPoint(outPoint) {}
|
||||||
|
|
||||||
|
ADD_SERIALIZE_METHODS;
|
||||||
|
|
||||||
|
template <typename Stream, typename Operation>
|
||||||
|
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
|
||||||
|
{
|
||||||
|
READWRITE(name);
|
||||||
|
READWRITE(outPoint);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
typedef std::pair<std::string, CClaimValue> claimQueueEntryType;
|
typedef std::pair<std::string, CClaimValue> claimQueueEntryType;
|
||||||
|
|
||||||
typedef std::pair<std::string, CSupportValue> supportQueueEntryType;
|
typedef std::pair<std::string, CSupportValue> supportQueueEntryType;
|
||||||
|
|
||||||
typedef std::map<std::string, supportMapEntryType> supportMapType;
|
typedef std::map<std::string, supportMapEntryType> supportMapType;
|
||||||
|
|
||||||
typedef std::vector<outPointHeightType> outPointHeightRowType;
|
typedef std::vector<outPointHeightType> queueNameRowType;
|
||||||
|
typedef std::map<std::string, queueNameRowType> queueNameType;
|
||||||
|
|
||||||
typedef std::vector<nameOutPointHeightType> nameOutPointHeightRowType;
|
typedef std::vector<nameOutPointHeightType> insertUndoType;
|
||||||
typedef std::map<std::string, outPointHeightRowType > nameOutPointHeightMapType;
|
|
||||||
|
typedef std::vector<nameOutPointType> expirationQueueRowType;
|
||||||
|
typedef std::map<int, expirationQueueRowType> expirationQueueType;
|
||||||
|
|
||||||
typedef std::vector<claimQueueEntryType> claimQueueRowType;
|
typedef std::vector<claimQueueEntryType> claimQueueRowType;
|
||||||
typedef std::map<int, claimQueueRowType> claimQueueType;
|
typedef std::map<int, claimQueueRowType> claimQueueType;
|
||||||
|
@ -277,12 +300,12 @@ public:
|
||||||
void setExpirationTime(int t);
|
void setExpirationTime(int t);
|
||||||
|
|
||||||
bool getQueueRow(int nHeight, claimQueueRowType& row) const;
|
bool getQueueRow(int nHeight, claimQueueRowType& row) const;
|
||||||
bool getQueueNameRow(const std::string& name, outPointHeightRowType& row) const;
|
bool getQueueNameRow(const std::string& name, queueNameRowType& row) const;
|
||||||
bool getExpirationQueueRow(int nHeight, claimQueueRowType& row) const;
|
bool getExpirationQueueRow(int nHeight, expirationQueueRowType& row) const;
|
||||||
bool getSupportNode(std::string name, supportMapEntryType& node) const;
|
bool getSupportNode(std::string name, supportMapEntryType& node) const;
|
||||||
bool getSupportQueueRow(int nHeight, supportQueueRowType& row) const;
|
bool getSupportQueueRow(int nHeight, supportQueueRowType& row) const;
|
||||||
bool getSupportQueueNameRow(const std::string& name, outPointHeightRowType& row) const;
|
bool getSupportQueueNameRow(const std::string& name, queueNameRowType& row) const;
|
||||||
bool getSupportExpirationQueueRow(int nHeight, supportQueueRowType& row) const;
|
bool getSupportExpirationQueueRow(int nHeight, expirationQueueRowType& row) const;
|
||||||
|
|
||||||
bool haveClaim(const std::string& name, const COutPoint& outPoint) const;
|
bool haveClaim(const std::string& name, const COutPoint& outPoint) const;
|
||||||
bool haveClaimInQueue(const std::string& name, const COutPoint& outPoint,
|
bool haveClaimInQueue(const std::string& name, const COutPoint& outPoint,
|
||||||
|
@ -310,12 +333,12 @@ private:
|
||||||
bool update(nodeCacheType& cache, hashMapType& hashes,
|
bool update(nodeCacheType& cache, hashMapType& hashes,
|
||||||
std::map<std::string, int>& takeoverHeights,
|
std::map<std::string, int>& takeoverHeights,
|
||||||
const uint256& hashBlock, claimQueueType& queueCache,
|
const uint256& hashBlock, claimQueueType& queueCache,
|
||||||
nameOutPointHeightMapType& queueNameCache,
|
queueNameType& queueNameCache,
|
||||||
claimQueueType& expirationQueueCache, int nNewHeight,
|
expirationQueueType& expirationQueueCache, int nNewHeight,
|
||||||
supportMapType& supportCache,
|
supportMapType& supportCache,
|
||||||
supportQueueType& supportQueueCache,
|
supportQueueType& supportQueueCache,
|
||||||
nameOutPointHeightMapType& supportQueueNameCache,
|
queueNameType& supportQueueNameCache,
|
||||||
supportQueueType& supportExpirationQueueCache);
|
expirationQueueType& supportExpirationQueueCache);
|
||||||
bool updateName(const std::string& name, CClaimTrieNode* updatedNode);
|
bool updateName(const std::string& name, CClaimTrieNode* updatedNode);
|
||||||
bool updateHash(const std::string& name, uint256& hash);
|
bool updateHash(const std::string& name, uint256& hash);
|
||||||
bool updateTakeoverHeight(const std::string& name, int nTakeoverHeight);
|
bool updateTakeoverHeight(const std::string& name, int nTakeoverHeight);
|
||||||
|
@ -336,13 +359,13 @@ private:
|
||||||
void markNodeDirty(const std::string& name, CClaimTrieNode* node);
|
void markNodeDirty(const std::string& name, CClaimTrieNode* node);
|
||||||
void updateQueueRow(int nHeight, claimQueueRowType& row);
|
void updateQueueRow(int nHeight, claimQueueRowType& row);
|
||||||
void updateQueueNameRow(const std::string& name,
|
void updateQueueNameRow(const std::string& name,
|
||||||
outPointHeightRowType& row);
|
queueNameRowType& row);
|
||||||
void updateExpirationRow(int nHeight, claimQueueRowType& row);
|
void updateExpirationRow(int nHeight, expirationQueueRowType& row);
|
||||||
void updateSupportMap(const std::string& name, supportMapEntryType& node);
|
void updateSupportMap(const std::string& name, supportMapEntryType& node);
|
||||||
void updateSupportQueue(int nHeight, supportQueueRowType& row);
|
void updateSupportQueue(int nHeight, supportQueueRowType& row);
|
||||||
void updateSupportNameQueue(const std::string& name,
|
void updateSupportNameQueue(const std::string& name,
|
||||||
outPointHeightRowType& row);
|
queueNameRowType& row);
|
||||||
void updateSupportExpirationQueue(int nHeight, supportQueueRowType& row);
|
void updateSupportExpirationQueue(int nHeight, expirationQueueRowType& row);
|
||||||
|
|
||||||
void BatchWriteNode(CLevelDBBatch& batch, const std::string& name,
|
void BatchWriteNode(CLevelDBBatch& batch, const std::string& name,
|
||||||
const CClaimTrieNode* pNode) const;
|
const CClaimTrieNode* pNode) const;
|
||||||
|
@ -360,12 +383,12 @@ private:
|
||||||
uint256 hashBlock;
|
uint256 hashBlock;
|
||||||
|
|
||||||
claimQueueType dirtyQueueRows;
|
claimQueueType dirtyQueueRows;
|
||||||
nameOutPointHeightMapType dirtyQueueNameRows;
|
queueNameType dirtyQueueNameRows;
|
||||||
claimQueueType dirtyExpirationQueueRows;
|
expirationQueueType dirtyExpirationQueueRows;
|
||||||
|
|
||||||
supportQueueType dirtySupportQueueRows;
|
supportQueueType dirtySupportQueueRows;
|
||||||
nameOutPointHeightMapType dirtySupportQueueNameRows;
|
queueNameType dirtySupportQueueNameRows;
|
||||||
supportQueueType dirtySupportExpirationQueueRows;
|
expirationQueueType dirtySupportExpirationQueueRows;
|
||||||
|
|
||||||
nodeCacheType dirtyNodes;
|
nodeCacheType dirtyNodes;
|
||||||
supportMapType dirtySupportNodes;
|
supportMapType dirtySupportNodes;
|
||||||
|
@ -412,14 +435,14 @@ public:
|
||||||
uint256 getBestBlock();
|
uint256 getBestBlock();
|
||||||
void setBestBlock(const uint256& hashBlock);
|
void setBestBlock(const uint256& hashBlock);
|
||||||
|
|
||||||
bool incrementBlock(nameOutPointHeightRowType& insertUndo,
|
bool incrementBlock(insertUndoType& insertUndo,
|
||||||
claimQueueRowType& expireUndo,
|
claimQueueRowType& expireUndo,
|
||||||
nameOutPointHeightRowType& insertSupportUndo,
|
insertUndoType& insertSupportUndo,
|
||||||
supportQueueRowType& expireSupportUndo,
|
supportQueueRowType& expireSupportUndo,
|
||||||
std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const;
|
std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const;
|
||||||
bool decrementBlock(nameOutPointHeightRowType& insertUndo,
|
bool decrementBlock(insertUndoType& insertUndo,
|
||||||
claimQueueRowType& expireUndo,
|
claimQueueRowType& expireUndo,
|
||||||
nameOutPointHeightRowType& insertSupportUndo,
|
insertUndoType& insertSupportUndo,
|
||||||
supportQueueRowType& expireSupportUndo,
|
supportQueueRowType& expireSupportUndo,
|
||||||
std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const;
|
std::vector<std::pair<std::string, int> >& takeoverHeightUndo) const;
|
||||||
|
|
||||||
|
@ -439,12 +462,12 @@ private:
|
||||||
mutable std::set<std::string> dirtyHashes;
|
mutable std::set<std::string> dirtyHashes;
|
||||||
mutable hashMapType cacheHashes;
|
mutable hashMapType cacheHashes;
|
||||||
mutable claimQueueType claimQueueCache;
|
mutable claimQueueType claimQueueCache;
|
||||||
mutable nameOutPointHeightMapType claimQueueNameCache;
|
mutable queueNameType claimQueueNameCache;
|
||||||
mutable claimQueueType expirationQueueCache;
|
mutable expirationQueueType expirationQueueCache;
|
||||||
mutable supportMapType supportCache;
|
mutable supportMapType supportCache;
|
||||||
mutable supportQueueType supportQueueCache;
|
mutable supportQueueType supportQueueCache;
|
||||||
mutable nameOutPointHeightMapType supportQueueNameCache;
|
mutable queueNameType supportQueueNameCache;
|
||||||
mutable supportQueueType supportExpirationQueueCache;
|
mutable expirationQueueType supportExpirationQueueCache;
|
||||||
mutable std::set<std::string> namesToCheckForTakeover;
|
mutable std::set<std::string> namesToCheckForTakeover;
|
||||||
mutable std::map<std::string, int> cacheTakeoverHeights;
|
mutable std::map<std::string, int> cacheTakeoverHeights;
|
||||||
mutable int nCurrentHeight; // Height of the block that is being worked on, which is
|
mutable int nCurrentHeight; // Height of the block that is being worked on, which is
|
||||||
|
@ -469,16 +492,16 @@ private:
|
||||||
bool addClaimToQueues(const std::string& name, CClaimValue& claim) const;
|
bool addClaimToQueues(const std::string& name, CClaimValue& claim) const;
|
||||||
bool removeClaimFromQueue(const std::string& name, const COutPoint& outPoint,
|
bool removeClaimFromQueue(const std::string& name, const COutPoint& outPoint,
|
||||||
CClaimValue& claim) const;
|
CClaimValue& claim) const;
|
||||||
void addToExpirationQueue(claimQueueEntryType& entry) const;
|
void addToExpirationQueue(int nExpirationHeight, nameOutPointType& entry) const;
|
||||||
void removeFromExpirationQueue(const std::string& name, const COutPoint& outPoint,
|
void removeFromExpirationQueue(const std::string& name, const COutPoint& outPoint,
|
||||||
int nHeight) const;
|
int nHeight) const;
|
||||||
|
|
||||||
claimQueueType::iterator getQueueCacheRow(int nHeight,
|
claimQueueType::iterator getQueueCacheRow(int nHeight,
|
||||||
bool createIfNotExists) const;
|
bool createIfNotExists) const;
|
||||||
nameOutPointHeightMapType::iterator getQueueCacheNameRow(const std::string& name,
|
queueNameType::iterator getQueueCacheNameRow(const std::string& name,
|
||||||
bool createIfNotExists) const;
|
bool createIfNotExists) const;
|
||||||
claimQueueType::iterator getExpirationQueueCacheRow(int nHeight,
|
expirationQueueType::iterator getExpirationQueueCacheRow(int nHeight,
|
||||||
bool createIfNotExists) const;
|
bool createIfNotExists) const;
|
||||||
|
|
||||||
bool removeSupport(const std::string& name, const COutPoint& outPoint,
|
bool removeSupport(const std::string& name, const COutPoint& outPoint,
|
||||||
int nHeight, int& nValidAtHeight,
|
int nHeight, int& nValidAtHeight,
|
||||||
|
@ -493,16 +516,17 @@ private:
|
||||||
|
|
||||||
supportQueueType::iterator getSupportQueueCacheRow(int nHeight,
|
supportQueueType::iterator getSupportQueueCacheRow(int nHeight,
|
||||||
bool createIfNotExists) const;
|
bool createIfNotExists) const;
|
||||||
nameOutPointHeightMapType::iterator getSupportQueueCacheNameRow(const std::string& name,
|
queueNameType::iterator getSupportQueueCacheNameRow(const std::string& name,
|
||||||
bool createIfNotExists) const;
|
bool createIfNotExists) const;
|
||||||
supportQueueType::iterator getSupportExpirationQueueCacheRow(int nHeight,
|
expirationQueueType::iterator getSupportExpirationQueueCacheRow(int nHeight,
|
||||||
bool createIfNotExists) const;
|
bool createIfNotExists) const;
|
||||||
|
|
||||||
bool addSupportToQueues(const std::string& name, CSupportValue& support) const;
|
bool addSupportToQueues(const std::string& name, CSupportValue& support) const;
|
||||||
bool removeSupportFromQueue(const std::string& name, const COutPoint& outPoint,
|
bool removeSupportFromQueue(const std::string& name, const COutPoint& outPoint,
|
||||||
CSupportValue& support) const;
|
CSupportValue& support) const;
|
||||||
|
|
||||||
void addSupportToExpirationQueue(supportQueueEntryType& entry) const;
|
void addSupportToExpirationQueue(int nExpirationHeight,
|
||||||
|
nameOutPointType& entry) const;
|
||||||
void removeSupportFromExpirationQueue(const std::string& name,
|
void removeSupportFromExpirationQueue(const std::string& name,
|
||||||
const COutPoint& outPoint,
|
const COutPoint& outPoint,
|
||||||
int nHeight) const;
|
int nHeight) const;
|
||||||
|
|
|
@ -464,9 +464,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||||
pblock->nNonce = 0;
|
pblock->nNonce = 0;
|
||||||
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
||||||
nameOutPointHeightRowType dummyInsertUndo;
|
insertUndoType dummyInsertUndo;
|
||||||
claimQueueRowType dummyExpireUndo;
|
claimQueueRowType dummyExpireUndo;
|
||||||
nameOutPointHeightRowType dummyInsertSupportUndo;
|
insertUndoType dummyInsertSupportUndo;
|
||||||
supportQueueRowType dummyExpireSupportUndo;
|
supportQueueRowType dummyExpireSupportUndo;
|
||||||
std::vector<std::pair<std::string, int> > dummyTakeoverHeightUndo;
|
std::vector<std::pair<std::string, int> > dummyTakeoverHeightUndo;
|
||||||
trieCache.incrementBlock(dummyInsertUndo, dummyExpireUndo, dummyInsertSupportUndo, dummyExpireSupportUndo, dummyTakeoverHeightUndo);
|
trieCache.incrementBlock(dummyInsertUndo, dummyExpireUndo, dummyInsertSupportUndo, dummyExpireSupportUndo, dummyTakeoverHeightUndo);
|
||||||
|
|
|
@ -84,9 +84,9 @@ class CBlockUndo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<CTxUndo> vtxundo; // for all but the coinbase
|
std::vector<CTxUndo> vtxundo; // for all but the coinbase
|
||||||
nameOutPointHeightRowType insertUndo; // any claims that went from the queue to the trie
|
insertUndoType insertUndo; // any claims that went from the queue to the trie
|
||||||
claimQueueRowType expireUndo; // any claims that expired
|
claimQueueRowType expireUndo; // any claims that expired
|
||||||
nameOutPointHeightRowType insertSupportUndo; // any supports that went from the support queue to the support map
|
insertUndoType insertSupportUndo; // any supports that went from the support queue to the support map
|
||||||
supportQueueRowType expireSupportUndo; // any supports that expired
|
supportQueueRowType expireSupportUndo; // any supports that expired
|
||||||
std::vector<std::pair<std::string, int> > takeoverHeightUndo; // for any name that was taken over, the previous time that name was taken over
|
std::vector<std::pair<std::string, int> > takeoverHeightUndo; // for any name that was taken over, the previous time that name was taken over
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue