From 13736a6697c7eb4884a17ac1a927b9b205f5c276 Mon Sep 17 00:00:00 2001 From: Ben Hagen Date: Wed, 6 May 2026 09:08:28 +0200 Subject: [PATCH] sync: short-hex Debug for peer from --- src/sync.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sync.rs b/src/sync.rs index 570441ac..60284ff3 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -34,8 +34,8 @@ use crate::{ /// Can be serialized to bytes with [serde] to transfer between peers. pub type ProtocolMessage = crate::ranger::Message; -/// Byte representation of a `PeerId` from `iroh-net`. -// TODO: PeerId is in iroh-net which iroh-docs doesn't depend on. Add iroh-base crate with `PeerId`. +/// Byte representation of an iroh `EndpointId`. +// TODO: Consider `iroh::EndpointId` instead of raw bytes (`iroh` re-exports it from `iroh-base`). pub type PeerIdBytes = [u8; 32]; /// Max time in the future from our wall clock time that we accept entries for. @@ -47,7 +47,7 @@ pub type ContentStatusCallback = Arc n0_future::boxed::BoxFuture + Send + Sync + 'static>; /// Event emitted by sync when entries are added. -#[derive(Debug, Clone)] +#[derive(derive_more::Debug, Clone)] pub enum Event { /// A local entry has been added. LocalInsert { @@ -63,6 +63,8 @@ pub enum Event { /// Inserted entry. entry: SignedEntry, /// Peer that provided the inserted entry. + /// Debug matches [`iroh::PublicKey::fmt_short`] (first 5 bytes, lower hex). + #[debug("{}", hex::encode(&from[..5]))] from: PeerIdBytes, /// Whether download policies require the content to be downloaded. should_download: bool, @@ -72,13 +74,15 @@ pub enum Event { } /// Whether an entry was inserted locally or by a remote peer. -#[derive(Debug, Clone)] +#[derive(derive_more::Debug, Clone)] pub enum InsertOrigin { /// The entry was inserted locally. Local, /// The entry was received from the remote node identified by [`PeerIdBytes`]. Sync { /// The peer from which we received this entry. + /// Debug matches [`iroh::PublicKey::fmt_short`] (first 5 bytes, lower hex). + #[debug("{}", hex::encode(&from[..5]))] from: PeerIdBytes, /// Whether the peer claims to have the content blob for this entry. remote_content_status: ContentStatus,