1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! The handle both network halves ask where a peer is.
//!
//! It lives in its own module because **both of them need it and neither owns it**. The sending
//! side holds one to look a peer up before dialing; the receiving side implements
//! `listen::PeerDirectory` on it so the accept loop can ask whose nodes these are — and that
//! module is behind its own feature, so this says the name rather than linking it. It used to sit
//! in `send.rs`, which made `listen` reach across into it — so the
//! `listen` feature did not compile on its own, however plainly the manifest said the two were
//! independent. This module is compiled whenever either feature is on, and neither reaches into
//! the other any more.
use ;
use AttaccaApiClient;
/// The client this node asks Attacca where a peer is — **replaceable, because the connection it
/// belongs to is**.
///
/// It used to be a `OnceLock`, on the reasoning that a connection has one client and a slot that
/// can be overwritten is a slot that can be swapped. The first half is true and the second is the
/// wrong conclusion: a node's websocket drops and comes back — a laptop sleeps, a server rolls, a
/// network blips — and the `Link` reconnects and calls `set_api` again with a client for the new
/// connection. A write-once slot ignores that call and keeps the client bound to the dead one, so
/// every lookup after the first disconnect fails with `connection lost`, for good, on a node that
/// otherwise looks perfectly healthy. Observed live: a send worked, the socket reset once, and
/// every send after it failed identically until the process was restarted.
///
/// Nothing outside this node can reach `set`. The client always comes from a connection the node
/// itself established, so "could be overwritten" was never a way in — only a way to stay broken.
///
/// Cloning shares the slot, which is what lets one client serve both the send side and
/// `listen::serve_peers`'s directory.
;