fixed failing test, added cache size cap

This commit is contained in:
Brannon King 2019-09-09 12:04:55 -06:00
parent c309f811c1
commit d9e83ba216

View file

@ -612,10 +612,10 @@ bool CClaimTrieCacheBase::flush()
getMerkleHash(); getMerkleHash();
if (base->cacheNodes.height() > 40000)
base->cacheNodes.clear();
for (auto it = nodesToAddOrUpdate.begin(); it != nodesToAddOrUpdate.end(); ++it) { for (auto it = nodesToAddOrUpdate.begin(); it != nodesToAddOrUpdate.end(); ++it) {
if (it.depth() < 4) {
base->cacheNodes.copy(it, it.depth() == 3 || (it->flags & HASH_DIRTY && !it.hasChildren()));
}
bool removed = forDeleteFromBase.erase(it.key()); bool removed = forDeleteFromBase.erase(it.key());
if (it->flags & HASH_DIRTY) { if (it->flags & HASH_DIRTY) {
CClaimTrieDataNode node; CClaimTrieDataNode node;
@ -636,6 +636,12 @@ bool CClaimTrieCacheBase::flush()
batch.Erase(std::make_pair(TRIE_NODE_CLAIMS, name)); batch.Erase(std::make_pair(TRIE_NODE_CLAIMS, name));
} }
for (auto it = nodesToAddOrUpdate.begin(); it != nodesToAddOrUpdate.end(); ++it) {
if (it.depth() < 4) {
base->cacheNodes.copy(it, it.depth() == 3 || (it->flags & HASH_DIRTY && !it.hasChildren()));
}
}
fprintf(stderr, "Height: %d, Hits: %zu, Misses: %zu, Cache Size: %zu\n", nNextHeight, cacheHits, cacheMisses, base->cacheNodes.height()); fprintf(stderr, "Height: %d, Hits: %zu, Misses: %zu, Cache Size: %zu\n", nNextHeight, cacheHits, cacheMisses, base->cacheNodes.height());
cacheHits = cacheMisses = 0; cacheHits = cacheMisses = 0;