mark nodes unhealthy if over 100 blocks away from highest (#13)

This commit is contained in:
lalanza808 2022-08-29 00:54:42 -07:00 committed by GitHub
parent 310905237f
commit bac563254c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 6 deletions

View file

@ -9,6 +9,7 @@ from levin.bucket import Bucket
from levin.ctypes import *
from levin.constants import LEVIN_SIGNATURE
from xmrnodes.models import Node
from xmrnodes import config
@ -119,3 +120,11 @@ def retrieve_peers(host, port):
return peers
else:
return None
def get_highest_block(nettype, crypto):
highest = Node.select().where(
Node.validated == True,
Node.nettype == nettype,
Node.crypto == crypto
).order_by(Node.last_height.desc()).limit(1).first()
return highest.last_height