Spaces:
Running on Zero
Running on Zero
GitHub Actions commited on
Commit ·
ff86593
1
Parent(s): 481b78e
fix: Space node auto-joins its own relay hub on startup so remote peers see it
Browse files
app.py
CHANGED
|
@@ -501,6 +501,28 @@ if _webagent_dir.exists():
|
|
| 501 |
print(f"[hearthnet] webagent mount: {_me}")
|
| 502 |
_mount_bus_endpoints(result)
|
| 503 |
_mount_relay_endpoints(result, _relay_hub)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
return result
|
| 505 |
|
| 506 |
_gr_routes.App.create_app = staticmethod(_patched_create_app)
|
|
|
|
| 501 |
print(f"[hearthnet] webagent mount: {_me}")
|
| 502 |
_mount_bus_endpoints(result)
|
| 503 |
_mount_relay_endpoints(result, _relay_hub)
|
| 504 |
+
|
| 505 |
+
# Auto-join: the Space node registers itself in its own relay hub
|
| 506 |
+
# so remote nodes that connect see it in the roster immediately.
|
| 507 |
+
async def _self_join_relay() -> None:
|
| 508 |
+
try:
|
| 509 |
+
caps = [
|
| 510 |
+
f"{e.descriptor.name}@{e.descriptor.version[0]}.{e.descriptor.version[1]}"
|
| 511 |
+
for e in _node.bus.registry.all_local()
|
| 512 |
+
]
|
| 513 |
+
nid = getattr(_node, "node_id_full", _node.node_id)
|
| 514 |
+
_relay_hub.join(
|
| 515 |
+
nid,
|
| 516 |
+
display_name=_node.display_name,
|
| 517 |
+
community_id=_node.community_id,
|
| 518 |
+
capabilities=caps,
|
| 519 |
+
endpoint="",
|
| 520 |
+
)
|
| 521 |
+
print(f"[hearthnet] Space node '{_node.display_name}' joined local relay hub")
|
| 522 |
+
except Exception as _je:
|
| 523 |
+
print(f"[hearthnet] self-join relay failed: {_je}")
|
| 524 |
+
|
| 525 |
+
result.add_event_handler("startup", _self_join_relay)
|
| 526 |
return result
|
| 527 |
|
| 528 |
_gr_routes.App.create_app = staticmethod(_patched_create_app)
|