diff options
| author | tv <tv@krebsco.de> | 2026-10-27 01:34:15 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-27 01:34:15 +0100 |
| commit | 027a0920b81e7ee3e0f3eb4f0b3cbbb559133252 (patch) | |
| tree | eb3f0c51ad6594cb1515d28fcec839cdaf69156e /src/transport/identity.rs | |
| parent | 3b2773500379d14c7611eacc62c4709c1b406fd3 (diff) | |
admit nodeId and addresses in the API
Diffstat (limited to 'src/transport/identity.rs')
| -rw-r--r-- | src/transport/identity.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/transport/identity.rs b/src/transport/identity.rs index 712e1f9..6f000d0 100644 --- a/src/transport/identity.rs +++ b/src/transport/identity.rs @@ -49,6 +49,17 @@ const MAX_HINTS: usize = 8; /// anyone can send us proofs (keys are free), so the books are bounded. const MAX_ENTRIES: usize = 4096; +/// A send refused because the peer hasn't proven where it is yet (`send_encoded`): +/// expected when a peer known only from hints is first contacted, and retried. +#[derive(Debug, thiserror::Error)] +#[error("{0} hasn't proven where it is yet; asked where it is said to be")] +pub(crate) struct NotProven(String); + +/// Whether `error` is (or was caused by) a [`NotProven`]. +pub(crate) fn is_not_proven(error: &anyhow::Error) -> bool { + error.chain().any(|cause| cause.is::<NotProven>()) +} + /// What a node under the identity layer needs (`node::NodeConfig::identity`). #[derive(Clone)] pub(crate) struct IdentityConfig { @@ -426,10 +437,7 @@ impl Transport for IdentityTransport { for target in hints { self.shared.ask(&target, false); } - bail!( - "{} hasn't proven where it is yet; asked where it is said to be", - message.peer - ); + return Err(NotProven(message.peer.clone()).into()); } let mut inner = message.clone(); inner.peer = message.address.clone(); |
