diff options
| author | tv <tv@krebsco.de> | 2026-10-26 05:45:20 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-26 05:45:20 +0100 |
| commit | 51e8c8e38c05d98487784e21f9df54cc18875b8b (patch) | |
| tree | 5b3a6f85ed79549bea8c104d39b9069b40a8d2ef /src/transport | |
| parent | f12a839d6e6bdd29a86ac52d5de836519a41aaf0 (diff) | |
send bounded peer lists
Diffstat (limited to 'src/transport')
| -rw-r--r-- | src/transport/firewall.rs | 4 | ||||
| -rw-r--r-- | src/transport/mod.rs | 4 | ||||
| -rw-r--r-- | src/transport/mycelium/mod.rs | 4 | ||||
| -rw-r--r-- | src/transport/sim.rs | 5 | ||||
| -rw-r--r-- | src/transport/traffic.rs | 4 |
5 files changed, 21 insertions, 0 deletions
diff --git a/src/transport/firewall.rs b/src/transport/firewall.rs index c8592bd..23d91fe 100644 --- a/src/transport/firewall.rs +++ b/src/transport/firewall.rs @@ -65,6 +65,10 @@ impl Transport for FirewallTransport { self.inner.local_id() } + fn is_peer_id(&self, id: &str) -> bool { + self.inner.is_peer_id(id) + } + async fn resolve_seed(&self, seed: &str) -> Result<String> { self.inner.resolve_seed(seed).await } diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 14c5ee4..b2ce63f 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -323,6 +323,10 @@ pub trait Transport: Send + Sync { /// This node's identity on the transport (for Mycelium: its public key). fn local_id(&self) -> &str; + /// Whether `id` can be a node's identity on this transport (for Mycelium: a public + /// key). Identities other peers name to us (in a HELLO_REPLY) are checked with it. + fn is_peer_id(&self, id: &str) -> bool; + /// Resolves a seed (anything that leads to a node, e.g. an address) to that node's /// identity, as `local_id` gives it on that node. async fn resolve_seed(&self, seed: &str) -> Result<String>; diff --git a/src/transport/mycelium/mod.rs b/src/transport/mycelium/mod.rs index cbae567..0b74793 100644 --- a/src/transport/mycelium/mod.rs +++ b/src/transport/mycelium/mod.rs @@ -168,6 +168,10 @@ impl Transport for MyceliumTransport { &self.local_id } + fn is_peer_id(&self, id: &str) -> bool { + is_pubkey(id) + } + async fn resolve_seed(&self, hint: &str) -> Result<String> { if is_pubkey(hint) { return Ok(hint.to_owned()); diff --git a/src/transport/sim.rs b/src/transport/sim.rs index 675f382..05160f8 100644 --- a/src/transport/sim.rs +++ b/src/transport/sim.rs @@ -255,6 +255,11 @@ impl Transport for SimTransport { &self.id } + /// Any name will do. + fn is_peer_id(&self, id: &str) -> bool { + !id.is_empty() + } + /// A seed is a node ID; one no node has doesn't resolve (yet). async fn resolve_seed(&self, seed: &str) -> Result<String> { if self.net.is_known(seed) { diff --git a/src/transport/traffic.rs b/src/transport/traffic.rs index 3d17860..78c5fee 100644 --- a/src/transport/traffic.rs +++ b/src/transport/traffic.rs @@ -138,6 +138,10 @@ impl Transport for CountingTransport { self.inner.local_id() } + fn is_peer_id(&self, id: &str) -> bool { + self.inner.is_peer_id(id) + } + async fn resolve_seed(&self, seed: &str) -> Result<String> { self.inner.resolve_seed(seed).await } |
