Skip to main content

distributed_topic_tracker/
lib.rs

1#![doc = include_str!("../README.md")]
2
3mod config;
4mod crypto;
5mod dht;
6
7#[cfg(feature = "iroh-gossip")]
8mod gossip;
9#[cfg(feature = "iroh-gossip")]
10pub use gossip::{
11    AutoDiscoveryGossip, Bootstrap, BubbleMerge, GossipReceiver, GossipRecordContent, GossipSender,
12    MessageOverlapMerge, Publisher, Topic,
13};
14
15pub use config::{
16    BootstrapConfig, BootstrapConfigBuilder, BubbleMergeConfig, BubbleMergeConfigBuilder, Config,
17    ConfigBuilder, DhtConfig, DhtConfigBuilder, MergeConfig, MergeConfigBuilder,
18    MessageOverlapMergeConfig, MessageOverlapMergeConfigBuilder, PublisherConfig,
19    PublisherConfigBuilder, TimeoutConfig, TimeoutConfigBuilder, 
20};
21pub use crypto::{
22    DefaultSecretRotation, EncryptedRecord, Record, RecordPublisher, RotationHandle,
23    SecretRotation, TopicId, encryption_keypair, salt, signing_keypair,
24};
25pub use dht::Dht;
26
27/// These are part of the on-wire format: DO NOT CHANGE without increasing protocol version.
28pub const MAX_RECORD_PEERS: usize = 5;
29pub const MAX_MESSAGE_HASHES: usize = 5;
30
31/// Get the current Unix minute timestamp, optionally offset.
32///
33/// # Arguments
34///
35/// * `minute_offset` - Offset in minutes from now (can be negative)
36///
37/// # Example
38///
39/// ```ignore
40/// let now = unix_minute(0);
41/// let prev_minute = unix_minute(-1);
42/// ```
43#[doc(hidden)]
44pub fn unix_minute(minute_offset: i64) -> u64 {
45    ((chrono::Utc::now().timestamp() / 60).saturating_add(minute_offset))
46        .try_into()
47        .expect("timestamp overflow")
48}