Skip to content

Commit

Permalink
Loki -> Oxen
Browse files Browse the repository at this point in the history
  • Loading branch information
jagerman committed Jan 7, 2021
1 parent 868fd7d commit 007baea
Show file tree
Hide file tree
Showing 18 changed files with 150 additions and 150 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Loki Observer OMG block explorer
# Oxen Observer OMG block explorer

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

## Prerequisite packages
Expand All @@ -23,7 +23,7 @@ Quick and dirty setup instructions for now:
(Note that we require a very recent python3-jinja package (2.11+), which may not be installed by the
above.)

You'll also need to run lokid with `--lmq-local-control ipc:///path/to/loki-observer/mainnet.sock`.
You'll also need to run oxend with `--lmq-local-control ipc:///path/to/loki-observer/mainnet.sock`.

## Running in debug mode

Expand Down Expand Up @@ -60,13 +60,13 @@ Create a "vassal" config for loki-observer, `/etc/uwsgi-emperor/vassals/loki-obs
logger = file:logfile=/path/to/loki-observer/mainnet.log

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

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

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

config.lokid_rpc = 'ipc:///var/lib/loki/lokid.sock'
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:

Expand All @@ -88,4 +88,4 @@ make uwsgi restart (for example because you are changing things) then it is suff
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 a lokid.sock from a testnet or devnet lokid.
using testnet.py or devnet.py pointing to a oxend.sock from a testnet or devnet oxend.
10 changes: 5 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# into `mainnet.py`/`testnet.py`/etc.


# LMQ RPC endpoint of lokid; can be a unix socket 'ipc:///path/to/lokid.sock' (preferred) or a tcp
# LMQ RPC endpoint of oxend; can be a unix socket 'ipc:///path/to/oxend.sock' (preferred) or a tcp
# socket 'tcp://127.0.0.1:5678'. Typically you want this running with admin permission.
# Leave this as None here, and set it for each observer in the mainnet.py/testnet.py/etc. script.
lokid_rpc = None
oxend_rpc = None

# Default blocks per page for the index.
blocks_per_page=20
Expand All @@ -25,9 +25,9 @@
enable_mixins_details=True

# URLs to networks other than the one we are on:
mainnet_url='https://blocks.lokinet.dev'
testnet_url='https://testnet.lokinet.dev'
devnet_url='https://devnet.lokinet.dev'
mainnet_url='https://oxen.observer'
testnet_url='https://testnet.oxen.observer'
devnet_url='https://devnet.oxen.observer'

# Same as above, but these apply if we are on a .loki URL:
lokinet_mainnet_url='http://blocks.loki'
Expand Down
2 changes: 1 addition & 1 deletion devnet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from observer import app, config

config.lokid_rpc = 'ipc://lokid/devnet.sock'
config.oxend_rpc = 'ipc://oxend/devnet.sock'
16 changes: 8 additions & 8 deletions lmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import sys
from datetime import datetime, timedelta

lmq, lokid = None, None
lmq, oxend = None, None
def lmq_connection():
global lmq, lokid
global lmq, oxend
if lmq is None:
lmq = pylokimq.LokiMQ(pylokimq.LogLevel.warn)
lmq.max_message_size = 200*1024*1024
lmq.start()
if lokid is None:
lokid = lmq.connect_remote(config.lokid_rpc)
return (lmq, lokid)
if oxend is None:
oxend = lmq.connect_remote(config.oxend_rpc)
return (lmq, oxend)

cached = {}
cached_args = {}
Expand All @@ -31,7 +31,7 @@ class FutureJSON():
result in unbounded memory growth.
lmq - the lmq object
lokid - the lokid lmq connection id object
oxend - the oxend lmq connection id object
endpoint - the lmq endpoint, e.g. 'rpc.get_info'
cache_seconds - how long to cache the response; can be None to not cache it at all
cache_key - fixed string to enable different caches of the same endpoint
Expand All @@ -40,7 +40,7 @@ class FutureJSON():
timeout - maximum time to spend waiting for a reply
"""

def __init__(self, lmq, lokid, endpoint, cache_seconds=3, *, cache_key='', args=None, fail_okay=False, timeout=10):
def __init__(self, lmq, oxend, endpoint, cache_seconds=3, *, cache_key='', args=None, fail_okay=False, timeout=10):
self.endpoint = endpoint
self.cache_key = self.endpoint + cache_key
self.fail_okay = fail_okay
Expand All @@ -53,7 +53,7 @@ def __init__(self, lmq, lokid, endpoint, cache_seconds=3, *, cache_key='', args=
else:
self.json = None
self.args = args
self.future = lmq.request_future(lokid, self.endpoint, [] if self.args is None else [self.args], timeout=timeout)
self.future = lmq.request_future(oxend, self.endpoint, [] if self.args is None else [self.args], timeout=timeout)
self.cache_seconds = cache_seconds

def get(self):
Expand Down
2 changes: 1 addition & 1 deletion mainnet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from observer import app, config

config.lokid_rpc = 'ipc://lokid/mainnet.sock'
config.oxend_rpc = 'ipc://oxend/mainnet.sock'
Loading

0 comments on commit 007baea

Please sign in to comment.