add caching, remove nodes (only show peers on map)

This commit is contained in:
lza_menace 2021-06-18 13:15:35 -07:00
parent b7a2ae440d
commit 268912d0c1
3 changed files with 25 additions and 51 deletions

View file

@ -1,10 +1,14 @@
import sys
import socket
import pickle
from os import path
from requests import get as r_get
from levin.section import Section
from levin.bucket import Bucket
from levin.ctypes import *
from levin.constants import LEVIN_SIGNATURE
from requests import get as r_get
from xmrnodes import config
@ -54,6 +58,18 @@ def is_onion(url: str):
else:
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:
with open(pickle_file, 'rb') as f:
pickled_data = pickle.load(f)
return pickled_data
def retrieve_peers(host, port):
try:
print(f'[.] Connecting to {host}:{port}')