aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/hub_client.py
diff options
context:
space:
mode:
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: