diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 2de7caa98..0a10dff9d 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -330,6 +330,9 @@ class LBRYDaemon(jsonrpc.JSONRPC): if functionPath not in ALLOWED_DURING_STARTUP: return server.failure + if self.wallet_type == "lbryum" and functionPath in ['set_miner', 'get_miner_status']: + return server.failure + try: function = self._getFunction(functionPath) except jsonrpclib.Fault, f: @@ -1995,6 +1998,39 @@ class LBRYDaemon(jsonrpc.JSONRPC): d.addCallback(lambda r: self._render_response(r, OK_CODE)) return d + def jsonrpc_set_miner(self, p): + """ + Start of stop the miner, function only available when lbrycrd is set as the wallet + + Args: + run: True/False + Returns: + miner status, True/False + """ + + stat = p['run'] + if stat: + d = self.session.wallet.start_miner() + else: + d = self.session.wallet.stop_miner() + d.addCallback(lambda _: self.session.wallet.get_miner_status()) + d.addCallback(lambda r: self._render_response(r, OK_CODE)) + return d + + def jsonrpc_get_miner_status(self): + """ + Get status of miner + + Args: + None + Returns: + True/False + """ + + d = self.session.wallet.get_miner_status() + d.addCallback(lambda r: self._render_response(r, OK_CODE)) + return d + # def jsonrpc_update_name(self, metadata): # def _disp(x): # print x