distributed_topic_tracker/
lib.rs

1#![doc = include_str!("../README.md")]
2
3mod crypto;
4mod dht;
5
6#[cfg(feature = "iroh-gossip")]
7mod gossip;
8#[cfg(feature = "iroh-gossip")]
9pub use gossip::{
10    AutoDiscoveryGossip, Bootstrap, BubbleMerge, GossipReceiver, GossipRecordContent, GossipSender,
11    MessageOverlapMerge, Publisher, Topic, TopicId,
12};
13
14pub use crypto::{
15    DefaultSecretRotation, EncryptedRecord, Record, RecordPublisher, RecordTopic, RotationHandle,
16    SecretRotation, encryption_keypair, salt, signing_keypair,
17};
18pub use dht::Dht;
19
20/// Maximum number of bootstrap records allowed per topic per time slot (minute).
21///
22/// When publishing to the DHT, records are not published if this threshold
23/// has already been reached for the current minute slot.
24pub const MAX_BOOTSTRAP_RECORDS: usize = 100;
25
26/// Get the current Unix minute timestamp, optionally offset.
27///
28/// # Arguments
29///
30/// * `minute_offset` - Offset in minutes from now (can be negative)
31///
32/// # Example
33///
34/// ```ignore
35/// let now = unix_minute(0);
36/// let prev_minute = unix_minute(-1);
37/// ```
38pub fn unix_minute(minute_offset: i64) -> u64 {
39    ((chrono::Utc::now().timestamp() as f64 / 60.0f64).floor() as i64 + minute_offset) as u64
40}