feat: add probation and ban enforcement
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user