Init wot plugin

This commit is contained in:
Kevin F 2022-08-16 09:54:54 -05:00
parent b2ebc56419
commit 3b8644fa8f
3 changed files with 16 additions and 6 deletions

View File

@ -77,6 +77,7 @@ def daemon():
logger.info( logger.info(
f"Onionr daemon is running under pid {os.getpid()}", terminal=True) f"Onionr daemon is running under pid {os.getpid()}", terminal=True)
events.event('init', threaded=False) events.event('init', threaded=False)
events.event('afterinit', threaded=False)
events.event('daemon_start') events.event('daemon_start')
add_onionr_thread( add_onionr_thread(

View File

@ -1 +1,7 @@
plugin_apis = {} #
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

@ -43,7 +43,7 @@ import ujson
jsonrpc.manager.json = ujson jsonrpc.manager.json = ujson
# RPC modules map Onionr APIs to the RPC dispacher # RPC modules map Onionr APIs to the RPC dispacher
from rpc import blocks from rpc import blocks, pluginrpcmethods
class OnionrRPC(object): class OnionrRPC(object):
@ -57,6 +57,10 @@ class OnionrRPC(object):
return response.json return response.json
def on_afterinit(api, data=None):
pluginrpcmethods.add_plugin_rpc_methods()
def on_init(api, data=None): def on_init(api, data=None):
config = { config = {
#'server.socket_file': socket_file_path, #'server.socket_file': socket_file_path,
@ -68,4 +72,3 @@ def on_init(api, data=None):
add_onionr_thread( add_onionr_thread(
cherrypy.quickstart, 5, 'OnionrRPCServer', cherrypy.quickstart, 5, 'OnionrRPCServer',
OnionrRPC(), initial_sleep=0) OnionrRPC(), initial_sleep=0)