Browse Source

Cache reporting in AZ.

cl-refactor
Gav Wood 10 years ago
parent
commit
e3381fbe3f
  1. 34
      alethzero/MainWin.cpp
  2. 7
      libethereum/Client.cpp

34
alethzero/MainWin.cpp

@ -1145,10 +1145,42 @@ void Main::on_refresh_triggered()
refreshAll();
}
static std::string niceUsed(unsigned _n)
{
static const vector<std::string> c_units = { "bytes", "KB", "MB", "GB", "TB", "PB" };
unsigned u = 0;
while (_n > 10240)
{
_n /= 1024;
u++;
}
if (_n > 1000)
return toString(_n / 1000) + "." + toString((min<unsigned>(949, _n % 1000) + 50) / 100) + " " + c_units[u + 1];
else
return toString(_n) + " " + c_units[u];
}
void Main::refreshCache()
{
BlockChain::Statistics s = ethereum()->blockChain().usage();
ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal()));
QString t;
auto f = [&](unsigned n, QString l)
{
t += ("%1 " + l).arg(QString::fromStdString(niceUsed(n)));
};
f(s.memTotal(), "total");
t += " (";
f(s.memBlocks, "blocks");
t += ", ";
f(s.memReceipts, "receipts");
t += ", ";
f(s.memLogBlooms, "blooms");
t += ", ";
f(s.memBlockHashes + s.memTransactionAddresses, "hashes");
t += ", ";
f(s.memDetails, "family");
t += ")";
ui->cacheUsage->setText(t);
}
void Main::timerEvent(QTimerEvent*)

7
libethereum/Client.cpp

@ -620,7 +620,7 @@ void Client::doWork()
this_thread::sleep_for(chrono::milliseconds(100));
if (chrono::system_clock::now() - m_lastGarbageCollection > chrono::seconds(5))
{
// garbage collect on watches
// watches garbage collection
vector<unsigned> toUninstall;
{
Guard l(m_filterLock);
@ -633,9 +633,12 @@ void Client::doWork()
}
for (auto i: toUninstall)
uninstallWatch(i);
// blockchain GC
m_bc.garbageCollect();
m_lastGarbageCollection = chrono::system_clock::now();
}
m_bc.garbageCollect();
}
unsigned Client::numberOf(int _n) const

Loading…
Cancel
Save