A tab in the debug window that shows the currently connected peers (with their address, port, connect time, starting height, incoming/outgoing, etc…) would be useful.
n.b.: this information can already be queried through RPC getpeerinfo
A tab in the debug window that shows the currently connected peers (with their address, port, connect time, starting height, incoming/outgoing, etc…) would be useful.
n.b.: this information can already be queried through RPC getpeerinfo
Hi laanwj. I left you a message on IRC but it might be better to track things here.
I can devote some time to getting this feature implemented, but since I’m new to QT, it would really help me if you could sketch up a really basic design. Just some quick notes in terms of where the model code would go (is a new model class needed?), what GUI widgets to use (QTableView?), and where/when to emit signals to update the GUI.
I’ve reviewed some previous patches to the debug console, ce14345a (network traffic graph), and 4d3dda5d (button to open debug.log), so I’ve gotten a feel for how the code is structured, but I still feel like I need some design notes for how to best implement this particular feature.
BTW when I say “design” I just mean the code design, not UI. I’ll just focus on getting the data to appear on a tab at first, then I’ll post screenshots and we could iterate through the UI to get it right.
Thanks.
@ashleyholman I took a look at this issue last week. I wanted to see how far I could go being a complete beginner in C++ and Qt myself, so I dedicated some time to it. I probably won’t be able to finish it, but I can tell you what I found in my quick investigation.
A new model class is probably needed. I believe you can get it to work using the QStandardItemModel
class directly, but subclassing it is probably more elegant and maintainable. UI wise, I guess the best option is to place a QTableView
under a new “Connected Peers” tab in the rpcconsole. For updating the view, you can hook initially to the NotifyNumConnectionsChanged()
signal and look at the code for getting the peers from the getpeerinfo
function in src/rpcnet.cpp
. This won’t work for the final implementation though, because peers could change without changing the total number of them. You could modify the code in ThreadSocketHandler
from src/net.cpp
to also notify when there are any peer changes, regardless of wether the number of connections changed or not.
@ashleyholman Thanks for picking this up. You’re on the right track. For polling node statistics it makes sense to just update them at regular intervals. Indeed, to probe every second or so.
Like the other GUI polling functions we’d want to make this poll optional. Start the timer handler with a TRY_LOCK on cs_vNodes, and if you don’t get the lock, skip this update this time. This avoids hanging the GUI thread on the lock. You can release the lock immediately after copying the data.
You could use the NotifyNumConnectionsChanged() signal as @federicobond mentions to be notified when new nodes could be added or nodes disconnected instantly. This would introduce a possible DoS risk because a node could connect/disconnect 100s of times per second, updating the table every time.
(this is always a compromise; at some point with continuous or fast-changing statistics polling is preferable to change notifications; a thermometer that sends a message every time the temperature changes would clog up all bandwidth)
Just some quick notes in terms of where the model code would go (is a new model class needed?)
Maybe a PeerTableModel
that is part of the ClientModel
. It could live in its own cpp/h files.
what GUI widgets to use (QTableView?)
What GUI to use is up to you :) In my mind there would be a table that shows the most important statistics for every node, and maybe a details window/pane that can show the nitty gritty details that don’t fit into the table.
Indeed, using QTableView would be consistent with what is used for the transactions list, address lists, etc. It’s also easiest to get a grid of information that way. @rebroad That would be useful, but I’d prefer if that is handled in a separate pull that adds that information to the RPC first. When first adding this to the GUI let’s show what is in getpeerinfo already, so that the change is manageable.
laanwj
ashleyholman
rebroad
federicobond
Labels
GUI