Refactor onionrpluginapi

This commit is contained in:
Arinerron 2018-05-15 19:16:33 -07:00
parent e50659753a
commit 3c8cbd2291
No known key found for this signature in database
GPG Key ID: 99383627861C62F0

View File

@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
import onionrplugins, logger import onionrplugins, core as onionrcore, logger
class DaemonAPI: class DaemonAPI:
def __init__(self, pluginapi): def __init__(self, pluginapi):
@ -136,6 +136,10 @@ class pluginapi:
def __init__(self, onionr, data): def __init__(self, onionr, data):
self.onionr = onionr self.onionr = onionr
self.data = data self.data = data
if self.onionr is None:
self.core = onionrcore.Core()
else:
self.core = self.onionr.onionrCore
self.daemon = DaemonAPI(self) self.daemon = DaemonAPI(self)
self.plugins = PluginAPI(self) self.plugins = PluginAPI(self)
@ -148,10 +152,10 @@ class pluginapi:
return self.data return self.data
def get_core(self): def get_core(self):
return self.get_onionr().onionrCore return self.core
def get_utils(self): def get_utils(self):
return self.get_onionr().onionrUtils return self.get_core()._utils
def get_crypto(self): def get_crypto(self):
return self.get_core()._crypto return self.get_core()._crypto