summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/hub_client.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-11 22:16:59 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-11 22:16:59 +0200
commitc66ee41d8476461939c5f4e7fdc71c5d7fb4a85c (patch)
tree6aea861849ad38d6c3aa4a0fe9bc1ed5ae7dce9f /packages/meshbay-node/src/meshbay_node/hub_client.py
parentbbfc45925e82c364519b9d796758003365bc9005 (diff)
downloadmeshbay-c66ee41d8476461939c5f4e7fdc71c5d7fb4a85c.tar.gz
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 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/hub_client.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/hub_client.py21
1 files changed, 21 insertions, 0 deletions
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: