MCPcopy Create free account
hub / github.com/ElementsProject/elements / ClientModel

Method ClientModel

src/qt/clientmodel.cpp:33–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31static int64_t nLastBlockTipUpdateNotification = 0;
32
33ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QObject *parent) :
34 QObject(parent),
35 m_node(node),
36 optionsModel(_optionsModel),
37 peerTableModel(nullptr),
38 banTableModel(nullptr),
39 m_thread(new QThread(this))
40{
41 cachedBestHeaderHeight = -1;
42 cachedBestHeaderTime = -1;
43
44 peerTableModel = new PeerTableModel(m_node, this);
45 m_peer_table_sort_proxy = new PeerTableSortProxy(this);
46 m_peer_table_sort_proxy->setSourceModel(peerTableModel);
47
48 banTableModel = new BanTableModel(m_node, this);
49
50 QTimer* timer = new QTimer;
51 timer->setInterval(MODEL_UPDATE_DELAY);
52 connect(timer, &QTimer::timeout, [this] {
53 // no locking required at this point
54 // the following calls will acquire the required lock
55 Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage());
56 Q_EMIT bytesChanged(m_node.getTotalBytesRecv(), m_node.getTotalBytesSent());
57 });
58 connect(m_thread, &QThread::finished, timer, &QObject::deleteLater);
59 connect(m_thread, &QThread::started, [timer] { timer->start(); });
60 // move timer to thread so that polling doesn't disturb main event loop
61 timer->moveToThread(m_thread);
62 m_thread->start();
63 QTimer::singleShot(0, timer, []() {
64 util::ThreadRename("qt-clientmodl");
65 });
66
67 subscribeToCoreSignals();
68}
69
70ClientModel::~ClientModel()
71{

Callers

nothing calls this directly

Calls 5

getMempoolSizeMethod · 0.80
getTotalBytesRecvMethod · 0.80
getTotalBytesSentMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected