From c66ee41d8476461939c5f4e7fdc71c5d7fb4a85c Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Tue, 11 Aug 2026 22:16:59 +0200 Subject: feat(node): index push to WebRTC peers + swarm registration (11.5, 11.9) When watchdog detects file changes, the daemon now: - Pushes INDEX_SYNC to all connected WebRTC peers in that group - Registers file hashes with hub /v1/swarm/register endpoint Also registers all file hashes on startup for initial discovery. hub_client: add register_swarm() method for bulk hash registration. Co-Authored-By: Claude Opus 4.6 --- .../meshbay-node/src/meshbay_node/hub_client.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'packages/meshbay-node/src/meshbay_node/hub_client.py') diff --git a/packages/meshbay-node/src/meshbay_node/hub_client.py b/packages/meshbay-node/src/meshbay_node/hub_client.py index ca0e776..ba9d3ff 100644 --- a/packages/meshbay-node/src/meshbay_node/hub_client.py +++ b/packages/meshbay-node/src/meshbay_node/hub_client.py @@ -329,6 +329,27 @@ class HubClient: finally: self._ws = None + # ── Swarm registration ───────────────────────────────────────────────── + + async def register_swarm(self, content_hashes: list[str], endpoint: str) -> int: + """Register file hashes in the hub swarm table. Returns count registered.""" + if self._session is None: + raise RuntimeError("Not logged in") + await self.ensure_fresh_token() + + registered = 0 + for h in content_hashes: + try: + r = await self._http.post("/v1/swarm/register", json={ + "content_hash": h, + "endpoint": endpoint, + }, headers=self._session.auth_headers) + if r.status_code in (201, 200): + registered += 1 + except Exception: + pass + return registered + # ── Convenience: full startup sequence ─────────────────────────────────── async def startup(self, endpoint_hint: str | None = None) -> HubSession: -- cgit v1.2.3