MCPcopy Create free account
hub / github.com/LUX-Core/lux / garbageCollect

Method garbageCollect

src/cpp-ethereum/libethereum/BlockChain.cpp:1182–1229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1180}
1181
1182void BlockChain::garbageCollect(bool _force)
1183{
1184 updateStats();
1185
1186 if (!_force && chrono::system_clock::now() < m_lastCollection + c_collectionDuration && m_lastStats.memTotal() < c_maxCacheSize)
1187 return;
1188 if (m_lastStats.memTotal() < c_minCacheSize)
1189 return;
1190
1191 m_lastCollection = chrono::system_clock::now();
1192
1193 Guard l(x_cacheUsage);
1194 WriteGuard l1(x_blocks);
1195 WriteGuard l2(x_details);
1196 WriteGuard l3(x_blockHashes);
1197 WriteGuard l4(x_receipts);
1198 WriteGuard l5(x_logBlooms);
1199 WriteGuard l6(x_transactionAddresses);
1200 WriteGuard l7(x_blocksBlooms);
1201 for (CacheID const& id: m_cacheUsage.back())
1202 {
1203 m_inUse.erase(id);
1204 // kill i from cache.
1205 switch (id.second)
1206 {
1207 case (unsigned)-1:
1208 m_blocks.erase(id.first);
1209 break;
1210 case ExtraDetails:
1211 m_details.erase(id.first);
1212 break;
1213 case ExtraReceipts:
1214 m_receipts.erase(id.first);
1215 break;
1216 case ExtraLogBlooms:
1217 m_logBlooms.erase(id.first);
1218 break;
1219 case ExtraTransactionAddress:
1220 m_transactionAddresses.erase(id.first);
1221 break;
1222 case ExtraBlocksBlooms:
1223 m_blocksBlooms.erase(id.first);
1224 break;
1225 }
1226 }
1227 m_cacheUsage.pop_back();
1228 m_cacheUsage.push_front(std::unordered_set<CacheID>{});
1229}
1230
1231void BlockChain::checkConsistency()
1232{

Callers 2

checkWatchGarbageMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 4

memTotalMethod · 0.80
backMethod · 0.80
pop_backMethod · 0.80
eraseMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64