Compare commits

..

No commits in common. "b59e79a21fe93c1f0918f9bfdbbc160e17a889c1" and "264eeaa988cd50fe6d2d63ad051998477de753fc" have entirely different histories.

13 changed files with 21 additions and 117 deletions

View File

@ -0,0 +1 @@
simplenotifications==0.2.18

View File

@ -0,0 +1,8 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --generate-hashes --output-file=requirements-notifications.txt requirements-notifications.in
#
simplenotifications==0.2.18 \
--hash=sha256:b7efd3d834b1922a3279287913d87fe4ef6fad181ca7edf54bfb8f1d973941e0

View File

@ -62,7 +62,7 @@ def daemon():
def _handle_sig_term(signum, frame):
sys.exit(0)
with open(filepaths.pid_file, 'w') as f:
f.write(str(os.getpid()))
@ -77,15 +77,14 @@ def daemon():
logger.info(
f"Onionr daemon is running under pid {os.getpid()}", terminal=True)
events.event('init', threaded=False)
events.event('afterinit', threaded=False)
events.event('daemon_start')
add_onionr_thread(
clean_block_database, 60, 'clean_block_database', initial_sleep=0)
Thread(
target=gossip.start_gossip_threads,
daemon=True,
target=gossip.start_gossip_threads,
daemon=True,
name='start_gossip_threads').start()
try:

View File

@ -21,7 +21,6 @@ import os, re, importlib
import traceback
from . import onionrevents as events
from .pluginapis import plugin_apis
import config, logger
from utils import identifyhome

View File

@ -1,7 +0,0 @@
#
from typing import Callable, Dict
# plugin apis are methods intended to be available to the rpc
# plugin, this is so plugins can provide apis to other plugins
# plugins add their methods during or before afterinit event
plugin_apis: Dict[str, Callable] = {}

View File

@ -28,12 +28,11 @@ def identify_home() -> str:
"""
path = os.environ.get('ONIONR_HOME', None)
if path is None:
system = platform.system()
if system == 'Linux':
path = os.environ.get(
'XDG_DATA_HOME',
os.path.expanduser('~') + '/.local/share/onionr/')
path = os.path.expanduser('~') + '/.local/share/onionr/'
elif system == 'Darwin':
path = os.path.expanduser('~' +
'/Library/Application Support/onionr/')

View File

@ -6,7 +6,6 @@ import sys
import os
import locale
from threading import Thread
from time import sleep
import cherrypy
@ -38,13 +37,11 @@ PLUGIN_VERSION = '0.0.0'
socket_file_path = identifyhome.identify_home() + 'rpc.sock'
from jsonrpc import JSONRPCResponseManager, dispatcher
import jsonrpc
import ujson
jsonrpc.manager.json = ujson
# RPC modules map Onionr APIs to the RPC dispacher
from rpc import blocks, pluginrpcmethods
@dispatcher.add_method
def foobar(**kwargs):
return kwargs["foo"] + kwargs["bar"]
class OnionrRPC(object):
@cherrypy.expose
@ -53,18 +50,16 @@ class OnionrRPC(object):
# Dispatcher is dictionary {<method_name>: callable}
data = cherrypy.request.body.read().decode('utf-8')
dispatcher["echo"] = lambda s: s
dispatcher["add"] = lambda a, b: a + b
response = JSONRPCResponseManager.handle(data, dispatcher)
return response.json
def on_afterinit(api, data=None):
pluginrpcmethods.add_plugin_rpc_methods()
def on_init(api, data=None):
config = {
#'server.socket_file': socket_file_path,
'server.socket_port': 0,
'server.socket_file': socket_file_path,
'engine.autoreload.on': False
}
cherrypy.config.update(config)

View File

@ -1,25 +0,0 @@
from secrets import randbits
from onionrblocks import Block
from jsonrpc import dispatcher
import ujson
from base64 import b85decode
from gossip.blockqueues import gossip_block_queues
from blockdb import get_blocks_after_timestamp
@dispatcher.add_method
def get_blocks(timestamp):
return [block.raw for block in get_blocks_after_timestamp(timestamp)]
queue_to_use = randbits(1)
@dispatcher.add_method
def insert_block(block):
block = Block(
block['id'], b85decode(block['raw']), auto_verify=False)
gossip_block_queues[queue_to_use].put_nowait(block)
return "ok"
#dispatcher['get_blocks_after_timestamp'] = get_blocks_after_timestamp

View File

@ -1,8 +0,0 @@
from jsonrpc import dispatcher
from onionrplugins.pluginapis import plugin_apis
def add_plugin_rpc_methods():
for method in plugin_apis:
dispatcher[method] = plugin_apis[method]

View File

@ -1 +0,0 @@
PYTHONPATH=./venv/bin/python310:../../src/:./

View File

@ -1,4 +0,0 @@
{ "name": "example",
"version": "0.0.0",
"author": "onionr"
}

View File

@ -1,52 +0,0 @@
"""Onionr - Private P2P Communication.
Default example plugin for devs or to test blocks
"""
import sys
import os
import locale
from time import sleep
import traceback
from typing import Set, TYPE_CHECKING
from threading import Thread, local
import blockdb
from gossip.peerset import gossip_peer_set
import logger
import onionrplugins
locale.setlocale(locale.LC_ALL, '')
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
# import after path insert
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
plugin_name = 'wot'
PLUGIN_VERSION = '0.0.0'
def wot_test(arg: int):
return arg + 1
def on_init(api, data=None):
logger.info(
f"Web of Trust Plugin v{PLUGIN_VERSION} enabled", terminal=True)
onionrplugins.plugin_apis['wot'] = wot_test