Skip to main content

weirdnet_net/
lib.rs

1#![doc = include_str!("../README.md")]
2pub mod addr;
3mod error;
4pub mod exchange;
5pub mod identity;
6pub mod invite;
7pub mod names;
8pub mod node;
9pub mod profile;
10pub mod sealed;
11pub mod shard;
12pub mod sync;
13pub mod user;
14
15pub use error::{NetError, Result};
16pub use exchange::{Answer, DEFAULT_TTL_MS, Derived, Offer, Token, normalize_code};
17pub use libp2p::identity::{Keypair, PublicKey};
18pub use libp2p::{Multiaddr, PeerId};
19pub use node::{Handler, Message, Node, NodeConfig, RelayLimits, Sighting, Status};
20pub use profile::{Profile, WEIRDNET};
21pub use weirdnet_keys::{Key32, Sealed};
22
23/// The last 8 characters of a peer id.
24pub fn short_peer_id(p: &PeerId) -> String {
25    identity::short_peer(&p.to_string()).to_string()
26}
27
28/// Milliseconds since the Unix epoch.
29pub fn now_ms() -> i64 {
30    std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_millis() as i64).unwrap_or(0)
31}
32
33#[cfg(test)]
34mod names_tests;
35#[cfg(test)]
36mod relay_tests;
37#[cfg(test)]
38mod tests;