Skip to content
364 changes: 298 additions & 66 deletions bittensor_cli/cli.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bittensor_cli/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def decode(key: str, default=""):

class Defaults:
netuid = 1
rate_tolerance = 0.005

class config:
base_path = "~/.bittensor"
Expand Down
14 changes: 14 additions & 0 deletions bittensor_cli/src/bittensor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,3 +1261,17 @@ def print_linux_dependency_message():
def is_linux():
"""Returns True if the operating system is Linux."""
return platform.system().lower() == "linux"

def validate_rate_tolerance(value: Optional[float]) -> Optional[float]:
"""Validates rate tolerance input"""
if value is not None:
if value < 0:
raise typer.BadParameter("Rate tolerance cannot be negative (less than 0%).")
if value > 1:
raise typer.BadParameter("Rate tolerance cannot be greater than 1 (100%).")
if value > 0.5:
console.print(
f"[yellow]Warning: High rate tolerance of {value*100}% specified. "
"This may result in unfavorable transaction execution.[/yellow]"
)
return value
Loading