From 7f6fdbab6c90360ab3b2d391a7b5aedc6f9721ac Mon Sep 17 00:00:00 2001 From: Bitflash Date: Wed, 29 Jul 2026 11:51:37 -0300 Subject: nostr: never advertise a rendezvous we are not registered at (#26) BtfActiveRelay() fell back to vBtfMeetingRelays[0] whenever registration had not completed yet. ThreadNostrSeed and ThreadBtfAccept start in parallel (net.cpp), so at boot that fallback was exactly what PublishDescriptor wrote into the descriptor -- including the one-time self-test, which publishes to every relay in the list. Peers reading it dialed a rendezvous this node was never registered at, and whenever the first seed happened to be down (92.246.128.180 was, for part of today) every one of those dials was wasted. BtfActiveRelay() now returns only the relay ThreadBtfAccept confirmed, and PublishDescriptor skips publishing until there is one. The seed loop republishes on every pass, so the only cost is the delay until registration succeeds; the self-test waits up to 60s for it so it still measures the publish/resolve chain instead of losing the race against it. Also fix the WebSocket handshake reader. On headers past the cap it did a bare break, leaving the socket parked in the middle of the header block -- and since the status line had already been read, the " 101 " check still passed, so the caller got a "connected" socket whose next bytes were leftover HTTP that the frame parser then read as garbage frames. It now errors out instead, and the cap is 8192 because relays behind Cloudflare send large header blocks. --- src/nostr.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nostr.h') diff --git a/src/nostr.h b/src/nostr.h index 37b3b05..04149e3 100644 --- a/src/nostr.h +++ b/src/nostr.h @@ -34,7 +34,8 @@ extern const int nNostrRelays; extern std::vector vBtfMeetingRelays; // The relay this node is currently registered at (set by ThreadBtfAccept). extern std::string strBtfActiveRelay; -// The active relay, or the first seed if none active yet ("" if the list is empty). +// The relay we are registered at, or "" if registration hasn't succeeded yet. +// Never guesses a seed: an unregistered node has no meeting node to advertise. std::string BtfActiveRelay(); // Record the relay this node just registered its service at (thread-safe). void BtfSetActiveRelay(const std::string& relay); -- cgit v1.2.3