adding p2pool

This commit is contained in:
anon 2022-08-08 16:05:59 -03:00
parent c02f961dce
commit 0a622c4d7f
3 changed files with 57 additions and 3 deletions

View file

@ -134,5 +134,16 @@ class DailyData(models.Model):
crypto_commentsPerHour = models.FloatField() crypto_commentsPerHour = models.FloatField()
crypto_postsPerHour = models.FloatField() crypto_postsPerHour = models.FloatField()
def __str__(self):
return self.date
class P2Pool(models.Model):
date = models.DateField()
hashrate = models.IntegerField()
percentage = models.FloatField()
miners = models.IntegerField()
totalhashes = models.IntegerField()
totalblocksfound = models.IntegerField()
def __str__(self): def __str__(self):
return self.date return self.date

View file

@ -1239,6 +1239,48 @@ def update_database(date_from=None, date_to=None):
return count return count
# Get latest P2Pool data
def get_latest_p2pool():
today = date.today()
yesterday = date.today() - timedelta(1)
today = datetime.datetime.strftime(today, '%Y-%m-%d')
try:
print(1)
P2Pool.objects.get(date=today)
print(2)
return False
except:
print(3)
try:
print(today)
coin = Coin.objects.filter(name='xmr').get(date=yesterday)
print(4)
if coin.hashrate > 0:
print(5)
pass
else:
print(6)
return False
except:
print(7)
return False
p2pool_stat = P2Pool()
p2pool_stat.date = today
response = requests.get('https://p2pool.io/api/pool/stats')
data = json.loads(response.text)
p2pool_stat.hashrate = data['pool_statistics']['hashRate']
p2pool_stat.percentage = 100*data['pool_statistics']['hashRate']/coin.hashrate
p2pool_stat.miners = data['pool_statistics']['miners']
p2pool_stat.totalhashes = data['pool_statistics']['3444692929009331,']
p2pool_stat.totalblocksfound = data['pool_statistics']['totalBlocksFound']
p2pool_stat.save()
print('p2pool saved!')
return True
########################################### ###########################################
# Views # Views
########################################### ###########################################
@ -1247,6 +1289,7 @@ def index(request):
if request.user.username != "Administrador" and request.user.username != "Morpheus": if request.user.username != "Administrador" and request.user.username != "Morpheus":
update_visitors(True) update_visitors(True)
get_latest_p2pool()
dt = datetime.datetime.now(timezone.utc).timestamp() dt = datetime.datetime.now(timezone.utc).timestamp()
symbol = 'xmr' symbol = 'xmr'

View file

@ -32,9 +32,9 @@ STATICFILES_DIRS = [
SECRET_KEY = 'dafsdasdfasfa7sdfs9d7das7f9as7df8ad43525fsffdssdg455$$###77saf9df79as79s' SECRET_KEY = 'dafsdasdfasfa7sdfs9d7das7f9as7df8ad43525fsffdssdg455$$###77saf9df79as79s'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
#DEBUG = True DEBUG = True
DEBUG = False #DEBUG = False
STATIC_ROOT = "/var/www/moneropro/static/" #STATIC_ROOT = "/var/www/moneropro/static/"
ALLOWED_HOSTS = ['www.moneroj.net', 'localhost', '127.0.0.1', 'moneroj.net', 'ilt7jgmfro76wgrtt6752lvfnhcz6wk5sjqhyvntjixygp3cwpvr4nad.onion'] ALLOWED_HOSTS = ['www.moneroj.net', 'localhost', '127.0.0.1', 'moneroj.net', 'ilt7jgmfro76wgrtt6752lvfnhcz6wk5sjqhyvntjixygp3cwpvr4nad.onion']