From 2593edca179e86883e74c7039629564f4ea6ec55 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Oct 2026 01:34:15 +0100 Subject: admit nodeId and addresses in the API --- src/transport/identity.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/transport') 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::()) +} + /// 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(); -- cgit v1.3.1