Skip to main content

mint_topic_id

Function mint_topic_id 

Source
pub fn mint_topic_id(file_hash: &str, sender_hex: &str) -> String
Expand description

Mint a fresh realtime-channel topic id for an outbound .xdc attachment.

32 bytes of SHA-256 over a domain separator + file hash + sender + send-time nanos + a per-process counter, encoded base32 (RFC 4648, no padding) — the same codec the miniapp realtime layer’s decode_topic_id expects, so the tag value round-trips into an iroh TopicId.

The counter is what actually guarantees re-sends are distinct sessions. The clock cannot: SystemTime::now() reports nanos but does not RESOLVE them, so two sends of the same file inside one tick hashed identical input and minted the same topic — the “fresh” session silently rejoined the previous one.