forked from LBRYCommunity/lbry-sdk
add set_miner and get_miner_status
set_miner takes parameter key ‘run’, which is True or False
This commit is contained in:
parent
b5e8aec548
commit
be96c77467
1 changed files with 36 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue