|
|
|
from peewee import *
|
|
|
|
from datetime import datetime
|
|
|
|
from xmrnodes import config
|
|
|
|
|
|
|
|
|
|
|
|
db = SqliteDatabase(f"{config.DATA_DIR}/sqlite.db")
|
|
|
|
|
|
|
|
class Node(Model):
|
|
|
|
id = AutoField()
|
|
|
|
url = CharField(unique=True)
|
|
|
|
is_tor = BooleanField(default=False)
|
|
|
|
available = BooleanField(default=False)
|
|
|
|
validated = BooleanField(default=False)
|
|
|
|
nettype = CharField(null=True)
|
|
|
|
last_height = IntegerField(null=True)
|
|
|
|
crypto = CharField(null=True)
|
|
|
|
datetime_entered = DateTimeField(default=datetime.utcnow)
|
|
|
|
datetime_checked = DateTimeField(default=None, null=True)
|
|
|
|
datetime_failed = DateTimeField(default=None, null=True)
|
|
|
|
fail_reason = CharField(null=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
database = db
|
|
|
|
|
|
|
|
class HealthCheck(Model):
|
|
|
|
id = AutoField()
|
|
|
|
node = ForeignKeyField(Node, backref='healthchecks')
|
|
|
|
datetime = DateTimeField(default=datetime.utcnow)
|
|
|
|
health = BooleanField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
database = db
|
|
|
|
|
|
|
|
db.create_tables([Node, HealthCheck])
|