Skip to content

Commit

Permalink
updated monitor scripts and adding vote_analysis.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Srayman committed Aug 9, 2019
1 parent 4940d38 commit aab23db
Show file tree
Hide file tree
Showing 5 changed files with 384 additions and 18 deletions.
17 changes: 6 additions & 11 deletions batch_difficulty.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,24 @@ def get_batch(all_multipliers: dict, node: str, block_hashes: list):
all_multipliers[h] = work_multiplier(work_value(work, previous))

def main(node, file):

try:
os.rename('multipliers.json','multipliers.json.'+datetime.utcnow().strftime("%Y%m%d%H%M%S"))
print('Renaming multipliers.json ...')
except:
print('multipliers.json does not exist, create new file ...')

outfile = 'multipliers_'+file[-15:]
print('Start - '+datetime.utcnow().strftime("%Y%m%d%H%M%S"))
with open(file, 'r') as f:
blocks = json.load(f)
all_hashes = [d['hash'] for d in blocks]

all_multipliers = dict()
split = 100000
split = 10000
chunks = [all_hashes[x:x+split] for x in range(0, len(all_hashes), split)]
print("{} chunks of {}...".format(len(chunks), split))
for i, hashes in enumerate(chunks):
print(i+1, end='...', flush=True)
get_batch(all_multipliers, node, hashes)
print('done')
print('Done - '+datetime.utcnow().strftime("%Y%m%d%H%M%S"))

with open('multipliers.json', 'w') as f:
with open(outfile, 'w') as f:
json.dump(all_multipliers, f)
print("Saved to multipliers.json")
print("Saved to "+outfile)

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down
19 changes: 19 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
host = '[::1]'
port = '55000'
socket = '57000'
save = 5
delay = 10
send = 'false'
dpow_enable = 'false'
dpow_url = ''
dpow_api_key = ''
dpow_user = ''
#BETA
betamonitor = ''
betawallet = ''
betaaccount = ''
#LIVE
monitor = 'nano_1311x3yriydwtbpkyenh1duqef74rntof7aaqf7drxddwnjdr1cntj9nrb9c'
wallet = ''
account = ''
representative = ''
8 changes: 4 additions & 4 deletions node_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
# importing the requests library
# pip install requests
import requests
import json
import time
import datetime
import statistics
from collections import defaultdict
from sys import exit
from time import sleep
from datetime import datetime
from datetime import timedelta

parser = argparse.ArgumentParser()
parser.add_argument('-host', '--node_url', type=str, help='Nano node url', default='localhost')
Expand All @@ -25,7 +25,7 @@
args = parser.parse_args()

json_data = []
timeString = datetime.utcnow().strftime("%Y-%m-%d")
timeString = (datetime.utcnow() + timedelta(hours=2)).strftime("%Y-%m-%d")
filename = 'stats_'+timeString+'.json'
#Rename existing file
try:
Expand Down Expand Up @@ -67,10 +67,10 @@ async def main():
data6 = {'action':'bootstrap_status'}

while 1:
filename2 = 'stats_'+datetime.utcnow().strftime("%Y-%m-%d")+'.json'
filename2 = 'stats_'+(datetime.utcnow() + timedelta(hours=2)).strftime("%Y-%m-%d")+'.json'
if filename2 != filename:
writeBkup()
timeString = datetime.utcnow().strftime("%Y-%m-%d")
timeString = (datetime.utcnow() + timedelta(hours=2)).strftime("%Y-%m-%d")
json_data = []
filename = filename2
loop_count += 1
Expand Down
7 changes: 4 additions & 3 deletions record_confirmations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sys import exit
from time import sleep
from datetime import datetime
from datetime import timedelta

parser = argparse.ArgumentParser()
parser.add_argument('-host', '--node_url', type=str, help='Nano node url', default='localhost')
Expand All @@ -26,7 +27,7 @@
json_data = []
hashes = []
distinct = []
timeString = datetime.utcnow().strftime("%Y-%m-%d")
timeString = (datetime.utcnow() + timedelta(hours=2)).strftime("%Y-%m-%d")
filename = 'confirmation_history_'+timeString+'.json'
#Rename existing file
try:
Expand Down Expand Up @@ -65,13 +66,13 @@ async def main():
data = {'action':'confirmation_history'}

while 1:
filename2 = 'confirmation_history_'+datetime.utcnow().strftime("%Y-%m-%d")+'.json'
filename2 = 'confirmation_history_'+(datetime.utcnow() + timedelta(hours=2)).strftime("%Y-%m-%d")+'.json'
if filename2 != filename:
writeBkup()
writeString = timeString+'|'+str(len(json_data))+'\n'
with open('files.txt', 'a') as files:
files.write(writeString)
timeString = datetime.utcnow().strftime("%Y-%m-%d")
timeString = (datetime.utcnow() + timedelta(hours=2)).strftime("%Y-%m-%d")
json_data = []
filename = filename2
loop_count += 1
Expand Down
Loading

0 comments on commit aab23db

Please sign in to comment.