| 31 | static int64_t nLastBlockTipUpdateNotification = 0; |
| 32 | |
| 33 | ClientModel::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 | |
| 70 | ClientModel::~ClientModel() |
| 71 | { |
nothing calls this directly
no test coverage detected