include nodes in the map view

main
lza_menace 1 year ago
parent 336bdb1e7c
commit 7513d0e9e3

@ -92,9 +92,12 @@ def rw_cache(key_name, data=None):
f.write(pickle.dumps(data))
return data
else:
with open(pickle_file, "rb") as f:
pickled_data = pickle.load(f)
return pickled_data
try:
with open(pickle_file, "rb") as f:
pickled_data = pickle.load(f)
return pickled_data
except:
return {}
def retrieve_peers(host, port):

@ -65,10 +65,16 @@ def index():
def map():
try:
peers = rw_cache("map_peers")
nodes = Node.select().where(Node.datetime_checked)
except:
flash("Couldn't load the map. Try again later.")
return redirect("/")
return render_template("map.html", peers=peers, source_node=config.NODE_HOST)
return render_template(
"map.html",
peers=peers,
nodes=nodes,
source_node=config.NODE_HOST
)
@bp.route("/about")

@ -56,14 +56,14 @@
{% endwith %}
<div class="center info">
<p>Peers seen ~24 hours: {{ peers | length }}</p>
<p>Peers seen ~2 weeks: {{ peers | length }}</p>
<p>Source Node: {{ source_node }}</p>
<p>
This is not a full representation of the entire Monero network,
just a look into the peers being recursively crawled from the source node ({{ source_node }}).
New peers are searched for once per day.
New peers are searched for once per week on average.
Older peers are shown as more transparent and will be removed
if not seen again after {{ config.PEER_LIFETIME }} hours.
if not seen again after some time.
</p>
<br>
<a href="/">Go home</a>
@ -95,8 +95,42 @@
})
});
{% for peer in peers %}
{% for peer in nodes %}
{% if peer.datetime_checked | hours_elapsed > 24 %}
{% set fill_color = 'rgba(1,1,45,.2)' %}
{% elif peer.datetime_checked | hours_elapsed > 16 %}
{% set fill_color = 'rgba(1,1,45,.4)' %}
{% elif peer.datetime_checked | hours_elapsed > 8 %}
{% set fill_color = 'rgba(1,1,45,.6)' %}
{% elif peer.datetime_checked | hours_elapsed > 4 %}
{% set fill_color = 'rgba(1,1,45,.8)' %}
{% else %}
{% set fill_color = 'rgba(1,1,45,1)' %}
{% endif %}
var feature = new ol.Feature(
new ol.geom.Point(ol.proj.transform(['{{ peer.lon }}', '{{ peer.lat }}'], 'EPSG:4326', 'EPSG:3857'))
);
feature.description = [
'Node {{ peer.url }}',
'Last seen {{ peer.datetime_checked | humanize }}'
];
feature.setStyle(new ol.style.Style({
image: new ol.style.Circle({
radius: 6,
fill: new ol.style.Fill({
color: '{{ fill_color }}',
}),
stroke: new ol.style.Stroke({
color: '#fff',
width: 1
})
})
})
);
markerLayer.getSource().addFeature(feature);
{% endfor %}
{% for peer in peers %}
{% if peer.datetime | hours_elapsed > 24 %}
{% set fill_color = 'rgba(238,111,45,.2)' %}
{% elif peer.datetime | hours_elapsed > 16 %}

Loading…
Cancel
Save