mirror of
https://github.com/cculianu/Fulcrum.git
synced 2026-08-17 13:07:35 +02:00
wip
This commit is contained in:
parent
89cd5e8901
commit
0f25722fb0
5 changed files with 82 additions and 0 deletions
|
|
@ -139,6 +139,20 @@ void Controller::startup()
|
|||
conns += connect(bitcoindmgr.get(), &BitcoinDMgr::allConnectionsLost, this, [this]{ stopTimer(mempoolLogTimer);});
|
||||
}
|
||||
|
||||
{
|
||||
// set up periodid refresh of mempool fee histogram
|
||||
constexpr const char *feeHistogramTimer = "feeHistogramTimer";
|
||||
constexpr int feeHistogramTimerInterval = 10 * 1000;//500 * 1000; // 500 seconds
|
||||
conns += connect(this, &Controller::upToDate, this, [this] {
|
||||
callOnTimerSoon(feeHistogramTimerInterval, feeHistogramTimer, [this]{
|
||||
refreshMempoolHistogram();
|
||||
return true;
|
||||
}, false, Qt::TimerType::VeryCoarseTimer);
|
||||
});
|
||||
// disable the timer if synchronizing and restart it later when up-to-date
|
||||
conns += connect(this, &Controller::synchronizing, this, [this]{ stopTimer(feeHistogramTimer); });
|
||||
}
|
||||
|
||||
start(); // start our thread
|
||||
}
|
||||
|
||||
|
|
@ -1172,6 +1186,23 @@ void Controller::process_DoUndoAndRetry()
|
|||
}
|
||||
}
|
||||
|
||||
void Controller::refreshMempoolHistogram() const
|
||||
{
|
||||
const auto t0 = Util::getTimeMicros();
|
||||
Mempool::FeeHistogramVec hist;
|
||||
{
|
||||
auto [mempool, lock] = storage->mempool();
|
||||
auto histtmp = mempool.calcCompactFeeHistogram();
|
||||
hist.swap(histtmp);
|
||||
}
|
||||
const auto elapsed = Util::getTimeMicros() - t0;
|
||||
Debug() << "Histogram: " << Util::Stringify(hist, [](const auto &val) {
|
||||
auto & [feeRate, cumSize] = val;
|
||||
return QString("(%1, %2)").arg(feeRate).arg(cumSize);
|
||||
});
|
||||
Debug() << "Refreshed mempool fee histogram in " << QString::number(elapsed/1e3, 'f', 4) << " msec";
|
||||
}
|
||||
|
||||
// -- CtlTask
|
||||
CtlTask::CtlTask(Controller *ctl, const QString &name)
|
||||
: QObject(nullptr), ctl(ctl)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue