Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.25 XMR BOUNTY] - meile_node_uptime.py - Limit requests to find remote_url #2

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 26 additions & 11 deletions meile_node_uptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,38 @@ def get_node_uptime_table(self,db):
def get_remote_url_of_node(self, db, NodeData):
NodeRemoteURL = {'address' : [], 'url' : []}

c = db.cursor()

for n in NodeData:
address = n['node_address']
endpoint = APIURL + '/nodes/' + address

try:
r = requests.get(endpoint)
remote_url = r.json()['result']['node']['remote_url']
NodeRemoteURL['address'].append(n['node_address'])
NodeRemoteURL['url'].append(remote_url)
except Exception as e:
print(str(e))
continue

#print(NodeRemoteURL)

# Retrieve remote_url from the table for nodes that have it stored
query = f"SELECT remote_url FROM node_uptime WHERE node_address = '{address}';"
c.execute(query)
result = c.fetchone()

if result['remote_url'] == '':
endpoint = APIURL + '/nodes/' + address
remote_url = result['remote_url']
print(f"Getting remote_url of: {address}", end=":")

try:
r = requests.get(endpoint)
remote_url = r.json()['result']['node']['remote_url']
except Exception as e:
print(str(e))
continue
print(f"{remote_url}")
else:
remote_url = result['remote_url']

NodeRemoteURL['address'].append(n['node_address'])
NodeRemoteURL['url'].append(remote_url)

return NodeRemoteURL



def check_uptime(self, NodeRemoteURLs):
k=0
Expand Down