Code Monkey home page Code Monkey logo

bisous's Introduction

bisous

Eth nodes vizualisation.

alt text

Besu

Download Besu from https://github.com/hyperledger/besu.
Modify the class PeerDiscoveryController to save the peers IP addresses (method addToPeerTable).
Run the local node and wait for a while.
I waited 30 minutes to get ~2,000 IPs.

ipstack

Get an API key from https://ipstack.com/.
Convert the IPs into longitude and latitude.

import requests
import time

end_point = "http://api.ipstack.com/"
suffix = "?access_key=YOUR_ACCES_KEY_HERE&format=1"

ipsf = open('ips.csv', 'r') 
outF = open("ipsll.csv", "w")
lines = ipsf.readlines() 
outF.write("c1, c2, c3, c4\n")

for line in lines: 
    start = time.time()
    ip = line.strip()
    url = end_point + ip + suffix
    response = requests.get(url)
    data = response.json()
    lat = data['latitude']
    lon = data['longitude']
    end = time.time()
    print("IP ", ip, lat, lon, (end-start))
    line = str(ip) + ", " + str(lat) + ", " + str(lon) + ", " +  str((end-start)) + "\n"
    outF.write(line)
    outF.flush()

outF.close()
print("Bye")

Folium

In a Jupyter notebook, draw the coordinates.
I used Folium

import folium
import pandas as pd 
from colour import Color

trackpoints = pd.read_csv("ipsll.csv", sep=r'\s*,\s*', engine='python') 

map = folium.Map(location=[1.3521, 103.8198])
folium.Marker(location=[1.3521, 103.8198], popup='SG').add_to(map)

for index, row in trackpoints.iterrows():
    lat = row['c2']
    lon = row['c3']
    if not pd.isna(lat):
        folium.CircleMarker(location=(lat, lon),
                            radius = 1,
                            color='red',
                            popup="Start",
                            fill=False).add_to(map)   
        

map.save('gviz.html')
map

Voila.

bisous's People

Watchers

James Cloos avatar TJ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.