Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_QT_PEERTABLEMODEL_H6#define BITCOIN_QT_PEERTABLEMODEL_H8#include <net_processing.h>9#include <net.h>11#include <QAbstractTableModel>12#include <QList>13#include <QModelIndex>14#include <QStringList>15#include <QVariant>17class PeerTablePriv;19namespace interfaces {20class Node;21}23QT_BEGIN_NAMESPACE24class QTimer;25QT_END_NAMESPACE27struct CNodeCombinedStats {28CNodeStats nodeStats;29CNodeStateStats nodeStateStats;30bool fNodeStateStatsAvailable;31};32Q_DECLARE_METATYPE(CNodeCombinedStats*)34/**35Qt model providing information about connected peers, similar to the36"getpeerinfo" RPC call. Used by the rpc console UI.37*/38class PeerTableModel : public QAbstractTableModel39{40Q_OBJECT42public:43explicit PeerTableModel(interfaces::Node& node, QObject* parent);44~PeerTableModel();45void startAutoRefresh();46void stopAutoRefresh();48enum ColumnIndex {49NetNodeId = 0,50Age,51Address,52Direction,53ConnectionType,54Network,55Ping,56Sent,57Received,58Subversion59};61enum {62StatsRole = Qt::UserRole,63};65/** @name Methods overridden from QAbstractTableModel66@{*/67int rowCount(const QModelIndex& parent = QModelIndex()) const override;68int columnCount(const QModelIndex& parent = QModelIndex()) const override;69QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;70QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;71QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;72Qt::ItemFlags flags(const QModelIndex &index) const override;73/*@}*/75public Q_SLOTS:76void refresh();78private:79//! Internal peer data structure.80QList<CNodeCombinedStats> m_peers_data{};81interfaces::Node& m_node;82const QStringList columns{83/*: Title of Peers Table column which contains a84unique number used to identify a connection. */85tr("Peer"),86/*: Title of Peers Table column which indicates the duration (length of time)87since the peer connection started. */88tr("Age"),89/*: Title of Peers Table column which contains the90IP/Onion/I2P address of the connected peer. */91tr("Address"),92/*: Title of Peers Table column which indicates the direction93the peer connection was initiated from. */94tr("Direction"),95/*: Title of Peers Table column which describes the type of96peer connection. The "type" describes why the connection exists. */97tr("Type"),98/*: Title of Peers Table column which states the network the peer99connected through. */100tr("Network"),101/*: Title of Peers Table column which indicates the current latency102of the connection with the peer. */103tr("Ping"),104/*: Title of Peers Table column which indicates the total amount of105network information we have sent to the peer. */106tr("Sent"),107/*: Title of Peers Table column which indicates the total amount of108network information we have received from the peer. */109tr("Received"),110/*: Title of Peers Table column which contains the peer's111User Agent string. */112tr("User Agent")};113QTimer* timer{nullptr};114};116#endif // BITCOIN_QT_PEERTABLEMODEL_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.