remove unused rw_cache

main
lza_menace 7 months ago
parent a44da731e9
commit 269a9c31a2

@ -9,7 +9,7 @@ from flask import Blueprint
from urllib.parse import urlparse from urllib.parse import urlparse
from xmrnodes.helpers import determine_crypto, is_onion, is_i2p, make_request from xmrnodes.helpers import determine_crypto, is_onion, is_i2p, make_request
from xmrnodes.helpers import retrieve_peers, rw_cache, get_highest_block, get_geoip from xmrnodes.helpers import retrieve_peers, get_highest_block, get_geoip
from xmrnodes.models import Node, HealthCheck, Peer from xmrnodes.models import Node, HealthCheck, Peer
from xmrnodes import config from xmrnodes import config
@ -146,8 +146,6 @@ def _get_peers():
print(f"[+] Found {len(peers_to_scan)} initial peers to begin scraping.") print(f"[+] Found {len(peers_to_scan)} initial peers to begin scraping.")
for peer in peers_to_scan: for peer in peers_to_scan:
upsert_peer(peer) upsert_peer(peer)
# rw_cache("map_peers", list(Peer.select().execute()))
@bp.cli.command("get_peers") @bp.cli.command("get_peers")
def get_peers(): def get_peers():

@ -83,23 +83,6 @@ def is_onion(url: str):
else: else:
return False return False
# Use hacky filesystem cache since i dont feel like shipping redis
def rw_cache(key_name, data=None):
pickle_file = path.join(config.DATA_DIR, f"{key_name}.pkl")
if data:
with open(pickle_file, "wb") as f:
f.write(pickle.dumps(data))
return data
else:
try:
with open(pickle_file, "rb") as f:
pickled_data = pickle.load(f)
return pickled_data
except:
return {}
def retrieve_peers(host, port): def retrieve_peers(host, port):
try: try:
sock = socket.socket() sock = socket.socket()

@ -5,7 +5,7 @@ from flask import request, redirect, Blueprint
from flask import render_template, flash, Response from flask import render_template, flash, Response
from urllib.parse import urlparse from urllib.parse import urlparse
from xmrnodes.helpers import rw_cache, get_highest_block from xmrnodes.helpers import get_highest_block
from xmrnodes.forms import SubmitNode from xmrnodes.forms import SubmitNode
from xmrnodes.models import Node, Peer from xmrnodes.models import Node, Peer
from xmrnodes import config from xmrnodes import config

Loading…
Cancel
Save