feat: add probation and ban enforcement
This commit is contained in:
@@ -9,6 +9,7 @@ import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from .downloader import download_shard
|
||||
from .hardware import detect_hardware
|
||||
@@ -38,6 +39,7 @@ def run_startup(
|
||||
cache_dir: Path | None = None,
|
||||
host: str = "127.0.0.1",
|
||||
advertise_host: str | None = None,
|
||||
contracts: Any | None = None,
|
||||
) -> StubNodeServer:
|
||||
"""Execute the full startup sequence and return a running node server.
|
||||
|
||||
@@ -73,6 +75,9 @@ def run_startup(
|
||||
wallet_kwargs["path"] = wallet_path
|
||||
_, _, address = load_or_create_wallet(**wallet_kwargs)
|
||||
print(f" Wallet: {address}", flush=True)
|
||||
probationary_line = _probationary_status_line(contracts, address)
|
||||
if probationary_line is not None:
|
||||
print(f" {probationary_line}", flush=True)
|
||||
|
||||
# 3. Shard assignment from tracker
|
||||
print("Querying tracker for shard assignment...", flush=True)
|
||||
@@ -152,3 +157,13 @@ def run_startup(
|
||||
)
|
||||
|
||||
return node
|
||||
|
||||
|
||||
def _probationary_status_line(contracts: Any | None, wallet_address: str) -> str | None:
|
||||
if contracts is None:
|
||||
return None
|
||||
remaining = contracts.registry.probationary_jobs_remaining(wallet_address)
|
||||
if remaining <= 0:
|
||||
return "Probationary period complete: earning enabled"
|
||||
suffix = "job" if remaining == 1 else "jobs"
|
||||
return f"Probationary period: {remaining} {suffix} remaining before earning"
|
||||
|
||||
Reference in New Issue
Block a user