From f71b87e34ae4855a4d1b3cf46a82ba453800989e Mon Sep 17 00:00:00 2001 From: "Maciek \"mab122\" Bator" Date: Thu, 23 Apr 2026 14:02:35 +0200 Subject: [PATCH] fix: reuse RNS instance when already running; setup detects seed liveness bridge.py / gossip.py: - Use RNS.Reticulum.get_instance() to reuse the running singleton instead of raising OSError when cmd_seed instantiates both RadicleBridge and GossipRelay with the same config_path cli.py (cmd_setup): - Added TCP port check via seed_node._port_open() to report whether the seed radicle-node is currently listening; prints start command if not - Adjusted final summary: distinguishes "all checks passed + running" from "all checks passed but not started" Co-Authored-By: Claude Sonnet 4.6 --- src/radicle_reticulum/bridge.py | 5 +++-- src/radicle_reticulum/cli.py | 16 ++++++++++++++-- src/radicle_reticulum/gossip.py | 3 ++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/radicle_reticulum/bridge.py b/src/radicle_reticulum/bridge.py index 2a2f9d9..bb61a12 100644 --- a/src/radicle_reticulum/bridge.py +++ b/src/radicle_reticulum/bridge.py @@ -123,8 +123,9 @@ class RadicleBridge: self.rad_home = rad_home self.state_path = state_path - # Initialize Reticulum - self.reticulum = RNS.Reticulum(config_path) + # Initialize Reticulum (reuse running instance if already started) + existing = RNS.Reticulum.get_instance() + self.reticulum = existing if existing is not None else RNS.Reticulum(config_path) # Identity if identity is None: diff --git a/src/radicle_reticulum/cli.py b/src/radicle_reticulum/cli.py index 37f21be..5da8def 100644 --- a/src/radicle_reticulum/cli.py +++ b/src/radicle_reticulum/cli.py @@ -676,8 +676,20 @@ def cmd_setup(args): ) print() - if ok: - print("All checks passed. Start the bridge with:") + print("Seed process...") + + seed_listening = seed_node._port_open() + check( + f"Seed radicle-node listening on port {seed_port}", + seed_listening, + f"radicle-rns seed --seed-home {seed_home} --seed-port {seed_port}", + ) + + print() + if ok and seed_listening: + print("All checks passed. Seed is running.") + elif ok: + print("All checks passed. Start the seed with:") print(f" radicle-rns seed") else: print("Setup incomplete. Follow the instructions above, then run:") diff --git a/src/radicle_reticulum/gossip.py b/src/radicle_reticulum/gossip.py index d15d0bc..2645beb 100644 --- a/src/radicle_reticulum/gossip.py +++ b/src/radicle_reticulum/gossip.py @@ -121,7 +121,8 @@ class GossipRelay: self.auto_discover = auto_discover self.rad_home = rad_home - self.reticulum = RNS.Reticulum(config_path) + existing = RNS.Reticulum.get_instance() + self.reticulum = existing if existing is not None else RNS.Reticulum(config_path) self.destination = RNS.Destination( identity.rns_identity,