chore: senior-review cleanup pass
- Remove Gemini's committed update_*.py regex-surgery scripts - Drop unused iroh-tickets dependency (hand-rolled ticket is used instead) - Replace ToString antipattern with Display impl on PeerSpeakTicket - Route debug log to XDG state/cache dir instead of hardcoded /home path - Clear all compiler + clippy warnings (unused imports, collapsible ifs, redundant pattern matching, missing Default) Builds clean with zero warnings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -114,12 +114,11 @@ impl RoomState for IrohGossipState {
|
||||
})
|
||||
};
|
||||
|
||||
if let Some(payload) = initial_payload {
|
||||
if let Ok(bytes) = serde_json::to_vec(&payload) {
|
||||
if let Some(payload) = initial_payload
|
||||
&& let Ok(bytes) = serde_json::to_vec(&payload) {
|
||||
crate::log_msg(&format!("Broadcasting initial state from self_id={:?}", self_id));
|
||||
let _ = gossip_sender_clone.broadcast(bytes.into()).await;
|
||||
}
|
||||
}
|
||||
|
||||
// Stream topic messages
|
||||
while let Some(res) = gossip_receiver.next().await {
|
||||
@@ -186,12 +185,11 @@ impl RoomState for IrohGossipState {
|
||||
msg: GossipMessage::Announce(state.clone()),
|
||||
})
|
||||
};
|
||||
if let Some(payload) = payload_opt {
|
||||
if let Ok(bytes) = serde_json::to_vec(&payload) {
|
||||
if let Some(payload) = payload_opt
|
||||
&& let Ok(bytes) = serde_json::to_vec(&payload) {
|
||||
crate::log_msg(&format!("Broadcasting state to new neighbor={:?}", peer_id));
|
||||
let _ = gossip_sender_clone.broadcast(bytes.into()).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(iroh_gossip::api::Event::NeighborDown(peer_id)) => {
|
||||
crate::log_msg(&format!("Gossip event: NeighborDown={:?}", peer_id));
|
||||
|
||||
@@ -94,7 +94,7 @@ impl NetworkTransport for IrohTransport {
|
||||
loop {
|
||||
match conn_clone.read_datagram().await {
|
||||
Ok(bytes) => {
|
||||
if let Err(_) = incoming_tx_inner.send((peer_id, bytes)).await {
|
||||
if incoming_tx_inner.send((peer_id, bytes)).await.is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-5
@@ -42,11 +42,16 @@ pub struct PeerSpeakTicket {
|
||||
pub topic_id: [u8; 32],
|
||||
}
|
||||
|
||||
impl ToString for PeerSpeakTicket {
|
||||
fn to_string(&self) -> String {
|
||||
let serialized = serde_json::to_vec(self).unwrap();
|
||||
// Convert to base64 URL-safe string
|
||||
base64::Engine::encode(&base64::engine::general_purpose::URL_SAFE_NO_PAD, &serialized)
|
||||
impl std::fmt::Display for PeerSpeakTicket {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
// serde_json on a struct of String/[u8;32] fields is infallible in practice,
|
||||
// but Display can't surface an error, so fall back to an empty ticket body.
|
||||
let serialized = serde_json::to_vec(self).unwrap_or_default();
|
||||
let encoded = base64::Engine::encode(
|
||||
&base64::engine::general_purpose::URL_SAFE_NO_PAD,
|
||||
&serialized,
|
||||
);
|
||||
f.write_str(&encoded)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user