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:
authorNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-11 16:38:49 -0300
committerNsable-sh <nsable-sh@noreply.git.bitflash.network>2026-08-11 16:38:49 -0300
commitc5f6b52c0d1d65f7bf8cd745a7a212bc6b2fe318 (patch)
tree7ad2835cd6cdca8808b202036525d0cde2380607 /src/net.h
parenta83fae37099cb102beb5a4c174a4abe6ef3f24a4 (diff)
net: replace peer select loop with poll
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/net.h b/src/net.h
index bcd0b2a..feecf96 100644
--- a/src/net.h
+++ b/src/net.h
@@ -98,19 +98,16 @@ static const int BTF_INCOMPLETE_MESSAGE_TIMEOUT_SECS = 2 * 60;
98 98
99// Ceiling on simultaneous connections. 99// Ceiling on simultaneous connections.
100// 100//
101// ThreadSocketHandler watches every peer through one select(), and select() 101// ThreadSocketHandler watches every peer in one socket loop. This used to be a
102// cannot watch more descriptors than FD_SETSIZE. On Windows FD_SET simply 102// select() loop, which made FD_SETSIZE the real limit and silently starved
103// stops adding once the set is full -- no error, no log -- so every socket 103// sockets past that bitmap. It is now poll()/WSAPoll(), so the ceiling below is
104// past the limit stays open and is never read again. Nothing capped vNodes, 104// a deliberate resource bound rather than a descriptor-set accident.
105// so a node accepted connections it had no way to service, and because new
106// entries go on the end of vNodes it was always the newest connection that
107// starved, including the ones dialed to fix connectivity.
108// 105//
109// Measured on two nodes before this ceiling existed: 277 and 90 CNode objects 106// Measured on two nodes before this ceiling existed: 277 and 90 CNode objects
110// against 93 and 90 live sockets, and a status bar reporting hundreds of 107// against 93 and 90 live sockets, and a status bar reporting hundreds of
111// peers for a node that was really talking to thirty. 108// peers for a node that was really talking to thirty.
112// 109//
113// 125 is Bitcoin's number and sits far below FD_SETSIZE on both platforms. 110// 125 is Bitcoin's number and remains a conservative public-node default.
114static const unsigned int MAX_CONNECTIONS = 125; 111static const unsigned int MAX_CONNECTIONS = 125;
115 112
116// A node marked for disconnect is normally held until its buffers drain, so 113// A node marked for disconnect is normally held until its buffers drain, so
@@ -142,7 +139,7 @@ static const int BTF_BEHIND_WARN_INTERVAL_SECS = 5 * 60;
142// 139//
143// These counters exist so it can. Cheap to keep, and they name the failures 140// These counters exist so it can. Cheap to keep, and they name the failures
144// that actually happened rather than the ones that sound impressive. 141// that actually happened rather than the ones that sound impressive.
145extern int nPeersWatched; // peers in the last select() set 142extern int nPeersWatched; // peers in the last poll() set
146extern int64 nBlocksReceived; // blocks handed to ProcessBlock 143extern int64 nBlocksReceived; // blocks handed to ProcessBlock
147extern int64 nBlocksWithoutParent; // ...of those, how many arrived orphaned 144extern int64 nBlocksWithoutParent; // ...of those, how many arrived orphaned
148 145