aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandymcmillan <randy.lee.mcmillan@gmail.com>2022-02-10 01:45:25 -0500
committerrandymcmillan <randy.lee.mcmillan@gmail.com>2022-03-16 04:54:52 -0400
commit209301a442512579d57f79c82417dc7c496248b6 (patch)
treeda6d243e4d780548635b7056d302eeba56bbce06
parent127de22c5fb396e1670d2a911faf7a9adc9241e2 (diff)
downloadbitcoin-209301a442512579d57f79c82417dc7c496248b6.tar.xz
gui: add Age column to peers tab
Co-authored-by: Jon Atack <jon@atack.com>
-rw-r--r--src/qt/peertablemodel.cpp3
-rw-r--r--src/qt/peertablemodel.h4
-rw-r--r--src/qt/peertablesortproxy.cpp2
3 files changed, 9 insertions, 0 deletions
diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp
index cd3193a1d2..32cb1f6ba0 100644
--- a/src/qt/peertablemodel.cpp
+++ b/src/qt/peertablemodel.cpp
@@ -71,6 +71,8 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
switch (column) {
case NetNodeId:
return (qint64)rec->nodeStats.nodeid;
+ case Age:
+ return GUIUtil::FormatPeerAge(rec->nodeStats.m_connected);
case Address:
return QString::fromStdString(rec->nodeStats.m_addr_name);
case Direction:
@@ -96,6 +98,7 @@ QVariant PeerTableModel::data(const QModelIndex& index, int role) const
} else if (role == Qt::TextAlignmentRole) {
switch (column) {
case NetNodeId:
+ case Age:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
case Address:
return {};
diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h
index 11064cdbfe..e2515de775 100644
--- a/src/qt/peertablemodel.h
+++ b/src/qt/peertablemodel.h
@@ -47,6 +47,7 @@ public:
enum ColumnIndex {
NetNodeId = 0,
+ Age,
Address,
Direction,
ConnectionType,
@@ -82,6 +83,9 @@ private:
/*: Title of Peers Table column which contains a
unique number used to identify a connection. */
tr("Peer"),
+ /*: Title of Peers Table column which indicates the duration (length of time)
+ since the peer connection started. */
+ tr("Age"),
/*: Title of Peers Table column which contains the
IP/Onion/I2P address of the connected peer. */
tr("Address"),
diff --git a/src/qt/peertablesortproxy.cpp b/src/qt/peertablesortproxy.cpp
index 26fedb4127..d87f10c365 100644
--- a/src/qt/peertablesortproxy.cpp
+++ b/src/qt/peertablesortproxy.cpp
@@ -24,6 +24,8 @@ bool PeerTableSortProxy::lessThan(const QModelIndex& left_index, const QModelInd
switch (static_cast<PeerTableModel::ColumnIndex>(left_index.column())) {
case PeerTableModel::NetNodeId:
return left_stats.nodeid < right_stats.nodeid;
+ case PeerTableModel::Age:
+ return left_stats.m_connected > right_stats.m_connected;
case PeerTableModel::Address:
return left_stats.m_addr_name.compare(right_stats.m_addr_name) < 0;
case PeerTableModel::Direction: