upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/nostr.cpp
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-08-02 11:59:12 -0300
committerGitHub <noreply@github.com>2026-08-02 11:59:12 -0300
commit758ff4bc49af78b06e37fc1e99741cb5fa8e43d6 (patch)
tree4e9d4ed63430d7a442260d1be78d63878a2fc455 /src/nostr.cpp
parentfe04a2045c3080797c6f93bf7cd2e12192b8f68f (diff)
rendezvous: let a node park more than one registration (#113)
A registration was consumed by the first caller and registering again replaced the previous one, so a node was reachable to one peer at a time and unreachable for the gap between being paired and registering again. Measured on a live node: descriptors resolved 53/54, our own registrations paired 11/12, nothing paired and went silent -- and half of every outbound dial failed, 15 of 30 in eleven minutes. The relay keeps a queue per pubkey capped at four, pairs with the oldest still-alive registration and discards the dead; the node runs three accept threads, each holding its own registration. The wire protocol does not change, so either side can be deployed first. Bench with both relays built from source and waves of concurrent dialers: old+1 65%, new+1 58%, old+3 68%, new+3 98%. Each half alone lands within noise of doing nothing.
Diffstat (limited to 'src/nostr.cpp')
-rw-r--r--src/nostr.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/nostr.cpp b/src/nostr.cpp
index dc96be2..1fd60ad 100644
--- a/src/nostr.cpp
+++ b/src/nostr.cpp
@@ -1596,6 +1596,8 @@ static void ConnectDiscoveredBtfPeers()
1596 // handshakes refused, which then looks exactly like "dead peers" even 1596 // handshakes refused, which then looks exactly like "dead peers" even
1597 // though the descriptors were perfectly resolvable. 1597 // though the descriptors were perfectly resolvable.
1598 map<string, BtfResolvedPeer> resolved; 1598 map<string, BtfResolvedPeer> resolved;
1599 for (const string& addr : candidates)
1600 BtfChurnNoteResolveAttempt();
1599 BtfResolveMany(candidates, resolved); 1601 BtfResolveMany(candidates, resolved);
1600 1602
1601 // Candidates whose descriptor didn't resolve this pass are recorded as a 1603 // Candidates whose descriptor didn't resolve this pass are recorded as a
@@ -1608,9 +1610,11 @@ static void ConnectDiscoveredBtfPeers()
1608 { 1610 {
1609 if (resolved.count(addr)) 1611 if (resolved.count(addr))
1610 { 1612 {
1613 BtfChurnNoteResolveResult(true);
1611 toDial.push_back(addr); 1614 toDial.push_back(addr);
1612 continue; 1615 continue;
1613 } 1616 }
1617 BtfChurnNoteResolveResult(false);
1614 int n = ++g_btfPeerFails[addr]; 1618 int n = ++g_btfPeerFails[addr];
1615 int64 cap = (n >= BTF_CHRONIC_FAIL_THRESHOLD) ? BTF_BACKOFF_CAP_SECS_DEAD 1619 int64 cap = (n >= BTF_CHRONIC_FAIL_THRESHOLD) ? BTF_BACKOFF_CAP_SECS_DEAD
1616 : BTF_BACKOFF_CAP_SECS; 1620 : BTF_BACKOFF_CAP_SECS;