feat: add probation and ban enforcement

This commit is contained in:
Dobromir Popov
2026-06-29 09:58:32 +03:00
parent 39f6f23c83
commit 792a9fd97f
8 changed files with 266 additions and 20 deletions

View File

@@ -83,6 +83,14 @@ def _select_route(
return route, ""
def _registration_ban_error(contracts: Any | None, wallet_address: str | None) -> str | None:
if contracts is None or not wallet_address:
return None
if contracts.registry.get_wallet(wallet_address).banned:
return "wallet is banned"
return None
class _TrackerHTTPServer(http.server.HTTPServer):
def __init__(
self,
@@ -205,6 +213,10 @@ class _TrackerHandler(http.server.BaseHTTPRequestHandler):
if wallet_address is not None and not isinstance(wallet_address, str):
self._send_json(400, {"error": "wallet_address must be a string"})
return
ban_error = _registration_ban_error(server.contracts, wallet_address)
if ban_error:
self._send_json(403, {"error": ban_error})
return
node_id = str(uuid.uuid4())
entry = _NodeEntry(