summaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-27 01:34:15 +0100
committertv <tv@krebsco.de>2026-10-27 01:34:15 +0100
commit2593edca179e86883e74c7039629564f4ea6ec55 (patch)
tree64257a6f5b1cf79b0e8d39bdfbfadb3e72c78e9c /src/transport
parent4cdece6d0f8e25ac154c3fd0f30bca604b08c16a (diff)
admit nodeId and addresses in the API
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/identity.rs16
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();