diff options
| author | Bitflash <btf01@proton.me> | 2026-08-02 11:59:12 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-02 11:59:12 -0300 |
| commit | 758ff4bc49af78b06e37fc1e99741cb5fa8e43d6 (patch) | |
| tree | 4e9d4ed63430d7a442260d1be78d63878a2fc455 /src/net.h | |
| parent | fe04a2045c3080797c6f93bf7cd2e12192b8f68f (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/net.h')
| -rw-r--r-- | src/net.h | 22 |
1 files changed, 22 insertions, 0 deletions
| @@ -54,6 +54,12 @@ static const int64 PEX_MIN_INTERVAL = 60; | |||
| 54 | // traffic is nothing: one per relay per five minutes. | 54 | // traffic is nothing: one per relay per five minutes. |
| 55 | static const int BTF_RENDEZVOUS_WAIT_SECS = 300; | 55 | static const int BTF_RENDEZVOUS_WAIT_SECS = 300; |
| 56 | 56 | ||
| 57 | // Registrations this node parks at a rendezvous at once. One is what the | ||
| 58 | // protocol needs; more is what keeps the node reachable while one of them is | ||
| 59 | // being paired, since pairing consumes the registration it used. Four matches | ||
| 60 | // the relay's ceiling per node. | ||
| 61 | static const int BTF_ACCEPT_THREADS = 3; | ||
| 62 | |||
| 57 | // Liveness of an established peer connection. BTF_RENDEZVOUS_WAIT_SECS bounds | 63 | // Liveness of an established peer connection. BTF_RENDEZVOUS_WAIT_SECS bounds |
| 58 | // the wait for a dial to arrive; these bound the connection that comes out of | 64 | // the wait for a dial to arrive; these bound the connection that comes out of |
| 59 | // it, which has the same failure mode once it goes quiet. | 65 | // it, which has the same failure mode once it goes quiet. |
| @@ -139,6 +145,18 @@ extern int nBestHeight; | |||
| 139 | // absurd height cannot move it. | 145 | // absurd height cannot move it. |
| 140 | int GetPeerMedianHeight(); | 146 | int GetPeerMedianHeight(); |
| 141 | 147 | ||
| 148 | // Lightweight .btf churn accounting. These counters are diagnostics only: they | ||
| 149 | // let an operator tell stale descriptors, relay pairing failures, and paired | ||
| 150 | // tunnels that never speak apart before changing behaviour. | ||
| 151 | void BtfChurnNoteResolveAttempt(); | ||
| 152 | void BtfChurnNoteResolveResult(bool fOk); | ||
| 153 | void BtfChurnNoteDialAttempt(const string& strBtfAddr, const string& strMeeting); | ||
| 154 | void BtfChurnNoteDialResult(const string& strBtfAddr, const string& strMeeting, bool fOk); | ||
| 155 | void BtfChurnNoteRegisterResult(const string& strMeeting, bool fOk); | ||
| 156 | void BtfChurnNotePairResult(const string& strMeeting, bool fOk); | ||
| 157 | void BtfChurnNoteHandshakeTimeout(const string& strBtfAddr, const string& strMeeting, | ||
| 158 | bool fRecv, bool fSend); | ||
| 159 | |||
| 142 | // Descriptors to hand a peer: ours first, then peers that answered us. | 160 | // Descriptors to hand a peer: ours first, then peers that answered us. |
| 143 | void BtfPexCollect(std::vector<std::string>& vDescOut); | 161 | void BtfPexCollect(std::vector<std::string>& vDescOut); |
| 144 | // Verify descriptors a peer sent and remember the good ones. Returns how many. | 162 | // Verify descriptors a peer sent and remember the good ones. Returns how many. |
| @@ -606,6 +624,8 @@ public: | |||
| 606 | int64 nIncompleteMessageStart; | 624 | int64 nIncompleteMessageStart; |
| 607 | unsigned int nIncompleteMessageSize; | 625 | unsigned int nIncompleteMessageSize; |
| 608 | string strIncompleteMessageCommand; | 626 | string strIncompleteMessageCommand; |
| 627 | string strBtfAddr; | ||
| 628 | string strBtfMeeting; | ||
| 609 | 629 | ||
| 610 | // Height this peer announced in its version message, or -1 if it sent a | 630 | // Height this peer announced in its version message, or -1 if it sent a |
| 611 | // version message that predates the field. Knowing how far along everyone | 631 | // version message that predates the field. Knowing how far along everyone |
| @@ -639,6 +659,8 @@ public: | |||
| 639 | nIncompleteMessageStart = 0; | 659 | nIncompleteMessageStart = 0; |
| 640 | nIncompleteMessageSize = 0; | 660 | nIncompleteMessageSize = 0; |
| 641 | strIncompleteMessageCommand.clear(); | 661 | strIncompleteMessageCommand.clear(); |
| 662 | strBtfAddr.clear(); | ||
| 663 | strBtfMeeting.clear(); | ||
| 642 | nStartingHeight = -1; | 664 | nStartingHeight = -1; |
| 643 | vfSubscribe.assign(256, false); | 665 | vfSubscribe.assign(256, false); |
| 644 | 666 | ||