Python based Oxen blockchain explorer
Find a file
Ian Macdonald 3feca6d743
Sort active nodes by last uptime proof.
Since HF19, there is no longer a concept of a per node reward height, so
we need a new sort criterion for active nodes. I believe the most
interesting sort is that by most recent uptime proof.

At the top of the list will appear nodes whose proof is overdue
(i.e. > 1:00:00 ago). This should never be more than a few seconds, so
one can see at a glance any nodes that are ripe for being moved to the
Inactive/Decommissioned Service Nodes section the next time they are
tested by the network. This also makes the list much more dynamic to
watch.

Since the Last Reward Height column is now redundant, we can replace it
with something more interesting, such as the Active Since Height.
2022-06-30 11:13:46 +02:00
contrib Add uwsgi-emperor vassal config 2020-08-19 19:43:59 -03:00
static Add active swarm count to service node list 2022-02-09 12:20:13 -04:00
templates Sort active nodes by last uptime proof. 2022-06-30 11:13:46 +02:00
.gitignore Add file for local site config options 2021-01-04 13:54:59 -04:00
base58.py Add moneropy local file 2021-07-15 13:16:25 +10:00
config.py Loki -> Oxen 2021-01-07 18:04:00 -04:00
devnet.py Switch to using new python3-oxenmq 2021-10-30 00:11:09 -03:00
LICENSE Add GPLv3 license 2020-10-06 21:33:07 -03:00
lmq.py Switch to using new python3-oxenmq 2021-10-30 00:11:09 -03:00
local_config.py Add file for local site config options 2021-01-04 13:54:59 -04:00
mainnet.py Switch to using new python3-oxenmq 2021-10-30 00:11:09 -03:00
observer.py HF10 updates 2022-06-14 20:18:28 -03:00
README.md Switch to using new python3-oxenmq 2021-10-30 00:11:09 -03:00
testnet.py Switch to using new python3-oxenmq 2021-10-30 00:11:09 -03:00

Oxen Observer OMG block explorer

Block explorer using Oxen 8+ LMQ RPC interface that does everything through RPC requests. Sexy, awesome, safe.

Prerequisite packages

sudo apt install build-essential pkg-config libsodium-dev libzmq3-dev python3-dev python3-flask python3-babel python3-pygments python3-oxenmq

Note that the last requirement (python3-oxenmq) comes from the Oxen repository (https://deb.oxen.io).

Running in debug mode

To run it in debug mode (production requires setting up a WSGI server, see below):

FLASK_APP=observer flask run --reload --debugger

This mode seems to be a bit flakey, though -- reloading, in particular, seems to break things and make it just silently exit after a while, so only do this for quick and dirty testing.

Setting up for production with uwsgi-emperor:

Do the above, but instead of running it with flask directly, set up uwsgi-emperor as follows:

apt install uwsgi-emperor uwsgi-plugin-python3

in /etc/uwsgi-emperor/emperor.ini add configuration of:

# vassals directory
emperor = /etc/uwsgi-emperor/vassals
cap = setgid,setuid
emperor-tyrant = true

Create a "vassal" config for oxen-observer, /etc/uwsgi-emperor/vassals/oxen-observer.ini, containing:

[uwsgi]
chdir = /path/to/oxen-observer
socket = mainnet.wsgi
plugins = python3,logfile
processes = 4
manage-script-name = true
mount = /=mainnet:app

logger = file:logfile=/path/to/oxen-observer/mainnet.log

Set ownership of this user to whatever user you want it to run as, and set the group to _loki (so that it can open the oxend unix socket):

chown MYUSERNAME:_loki /etc/uwsgi-emperor/vassals/loki-observer.ini

In the oxen-observer/mainnet.py, set:

config.oxend_rpc = 'ipc:///var/lib/loki/oxend.sock'

and finally, proxy requests from the webserver to the wsgi socket. For Apache I do this with:

# Allow access to static files (e.g. .css and .js):
<Directory /path/to/loki-observer/static>
    Require all granted
</Directory>
DocumentRoot /home/jagerman/src/loki-observer/static

# Proxy everything else via the uwsgi socket:
ProxyPassMatch "^/[^/]*\.(?:css|js)(?:$|\?)" !
ProxyPass / unix:/path/to/loki-observer/mainnet.wsgi|uwsgi://uwsgi-mainnet-observer/

(you will probably need to a2enmod proxy_uwsgi to enable the Apache modules that make that work).

That should be it: restart apache2 and uwsgi-emperor and you should be good to go. If you want to make uwsgi restart (for example because you are changing things) then it is sufficient to touch /etc/uwsgi-emperor/vassals/loki-observer.ini to trigger a reload (you do not have to restart the apache2/uwsgi-emperor layers).

If you want to set up a testnet or devnet observer the procedure is essentially the same, but using testnet.py or devnet.py pointing to the oxend.sock from a testnet or devnet oxend.