Registry Loading and Dynamic Swarms
#![allow(unused)]
fn main() {
**Files:** `registry.rs`, `swarm_manager.rs`
**Crate:** kinetic-atlas | **Stage:** 16
}
registry.rs — The TLD Mapping
TldRegistry loads .json configuration files from the local networks/ directory. Each JSON defines a Kinetic fork: its TLD (e.g. .alt), its network_id (used for isolating libp2p and signatures), its bootstrap nodes, and an optional seed domain.
Filtering:
Applies the global whitelist and blacklist arrays from atlas.json. If a network is blacklisted, it is skipped entirely.
PAC Integration:
Note
When a TLD is loaded, Atlas creates a JSON file in the OS local app data directory (e.g.,
~/.local/share/kinetic_pac/proxies/atlas_<tld>.json). Thekinetic-pacdaemon watches this directory and automatically configures system-wide proxy routing so that the OS knows to send traffic for that TLD to the Atlas port.
swarm_manager.rs — On-Demand Networking
Atlas does not start libp2p swarms for every TLD on startup. If you have 500 TLDs in the registry, starting 500 swarms would crash the machine.
The On-Demand Pattern:
get_or_spawn_swarm(tld): If a swarm for the TLD is already running, it returns the existing communication channel (mpsc::Sender<NetworkCommand>).- If not, it spawns a new
KineticAtlasNodein a background Tokio task. - Bootstrapping: If the registry entry has a
seed_domain(e.g.,seed.alt.network), it resolves the Kintree Merkle DNS tree to dynamically find P2P bootstrap IPs before starting the node.
Garbage Collection:
start_garbage_collector()runs a background loop every 60 seconds.- It iterates through the active swarms and checks their
last_usedtimestamp. - Any swarm that has not routed traffic for 10 minutes is gracefully shut down.