upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-08-01 12:23:31 -0300
committerGitHub <noreply@github.com>2026-08-01 12:23:31 -0300
commit24ed292f0524f1bc77c317b60d7ecf265596b3dd (patch)
treeacdbccfca6bc0725751af8e653c16b7797db8a3f /src/net.h
parent64b9507846846e468ebba7e00fb59971edceca3b (diff)
diag: let the node say what is wrong with it (#81)
* Bump to 1.2.11 One change, and it is the reason a node on Windows kept collecting peers it could not hear. FD_SETSIZE was never defined in this tree, so it defaulted to 64 and select() could watch the listen socket plus 63 peers -- everything past that stayed connected and was never read again. Windows FD_SET stops adding once its array is full and says nothing, so there was no error to notice. Because new connections go on the end of vNodes, it was always the newest connection that starved, including the ones dialed to fix connectivity. Measured on two nodes: 277 and 90 CNode objects against 93 and 90 live sockets, 316 and 355 sockets in a bound-but-never-connected state, and a status bar reporting hundreds of peers for a node really talking to thirty. 1.2.11 raises FD_SETSIZE to 1024 on Windows, caps connections at 125, drops a node stuck undeliverable after 60 seconds instead of holding it forever, stops answering a failed select() with POSIX code that has no meaning on Windows, and warns when there are more peers than select can watch. * diag: let the node say what is wrong with it Every hard problem in this project so far was found from outside the node -- sockets read over WMI, committed memory compared against a README, a grep over somebody debug.log. In each case the node knew and had no way to say so. One report, rendered identically for the GUI panel and the log: peers held vs peers actually watched by select(), blocks received and how many arrived without a parent, proof-of-work mode with the live miner thread count, and per peer the age of the last message in each direction plus anything stuck unsent.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index 01f314d..bd4eb77 100644
--- a/src/net.h
+++ b/src/net.h
@@ -102,6 +102,25 @@ static const int BTF_PING_INTERVAL_SECS = 10 * 60;
102static const int BTF_BEHIND_GRACE_SECS = 5 * 60; 102static const int BTF_BEHIND_GRACE_SECS = 5 * 60;
103static const int BTF_BEHIND_WARN_INTERVAL_SECS = 5 * 60; 103static const int BTF_BEHIND_WARN_INTERVAL_SECS = 5 * 60;
104 104
105// --- Self-diagnosis -------------------------------------------------------
106//
107// A node that has stopped working looks exactly like a node with nothing to
108// do. That has cost this project real time more than once: a node deaf to
109// most of its peers, a miner allocating one RandomX dataset per thread, a
110// third of arriving blocks missing their parent -- each was found from
111// outside, by reading the process's sockets or its memory from another
112// machine, because the node itself had no way to say so.
113//
114// These counters exist so it can. Cheap to keep, and they name the failures
115// that actually happened rather than the ones that sound impressive.
116extern int nPeersWatched; // peers in the last select() set
117extern int64 nBlocksReceived; // blocks handed to ProcessBlock
118extern int64 nBlocksWithoutParent; // ...of those, how many arrived orphaned
119
120// One report, rendered the same way for the GUI panel and the log, so what a
121// user pastes into an issue is what a developer already knows how to read.
122string GetDiagnosticsText();
123
105// Defined in main.cpp. Declared here because CNode announces it in the version 124// Defined in main.cpp. Declared here because CNode announces it in the version
106// message, and net.h is included before main.h. 125// message, and net.h is included before main.h.
107extern int nBestHeight; 126extern int nBestHeight;