Skip to content

Commit

Permalink
fix: update utils
Browse files Browse the repository at this point in the history
  • Loading branch information
drunest committed Sep 28, 2024
1 parent 6a69810 commit 7484ff7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions app/src/auto_validator/core/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf import settings
from django.shortcuts import redirect, render

from ..models import Hotkey, Server, Subnet, ValidatorInstance
from ..models import Subnet

GITHUB_URL = settings.SUBNETS_INFO_GITHUB_URL

Expand Down Expand Up @@ -46,11 +46,10 @@ def fetch_and_compare_subnets(request):
)


def get_subnet_by_hotkey(hotkey_ss58, ip_address):
try:
hotkey = Hotkey.objects.get(hotkey=hotkey_ss58)
server = Server.objects.get(ip_address=ip_address)
validator = ValidatorInstance.objects.get(hotkey=hotkey, server=server)
except ValidatorInstance.DoesNotExist:
return None
return validator.subnet_slot.subnet
def get_user_ip(request):
ip_address = request.META.get("HTTP_X_FORWARDED_FOR")
if ip_address:
ip_address = ip_address.split(",")[0]
else:
ip_address = request.META.get("REMOTE_ADDR")
return ip_address

0 comments on commit 7484ff7

Please sign in to comment.