Refresh Config Script
This commit is contained in:
parent
77301b2fb2
commit
94c5dc0804
@ -7,6 +7,7 @@ from stratum.pubsub import Pubsub
|
|||||||
from interfaces import Interfaces
|
from interfaces import Interfaces
|
||||||
from subscription import MiningSubscription
|
from subscription import MiningSubscription
|
||||||
from lib.exceptions import SubmitException
|
from lib.exceptions import SubmitException
|
||||||
|
import json
|
||||||
|
|
||||||
import lib.logger
|
import lib.logger
|
||||||
log = lib.logger.get_logger('mining')
|
log = lib.logger.get_logger('mining')
|
||||||
@ -21,6 +22,29 @@ class MiningService(GenericService):
|
|||||||
service_type = 'mining'
|
service_type = 'mining'
|
||||||
service_vendor = 'stratum'
|
service_vendor = 'stratum'
|
||||||
is_default = True
|
is_default = True
|
||||||
|
event = 'mining.notify'
|
||||||
|
|
||||||
|
@admin
|
||||||
|
def get_server_stats(self):
|
||||||
|
serialized = ''
|
||||||
|
for subscription in Pubsub.iterate_subscribers(self.event):
|
||||||
|
try:
|
||||||
|
if subscription != None:
|
||||||
|
session = subscription.connection_ref().get_session()
|
||||||
|
session.setdefault('authorized', {})
|
||||||
|
if session['authorized'].keys():
|
||||||
|
worker_name = session['authorized'].keys()[0]
|
||||||
|
difficulty = session['difficulty']
|
||||||
|
ip = subscription.connection_ref()._get_ip()
|
||||||
|
serialized += json.dumps({'worker_name': worker_name, 'ip': ip, 'difficulty': difficulty})
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
log.exception("Error getting subscriptions %s" % str(e))
|
||||||
|
pass
|
||||||
|
|
||||||
|
log.debug("Server stats request: %s" % serialized)
|
||||||
|
return '%s' % serialized
|
||||||
|
|
||||||
@admin
|
@admin
|
||||||
def update_block(self):
|
def update_block(self):
|
||||||
@ -43,6 +67,12 @@ class MiningService(GenericService):
|
|||||||
log.info("New litecoind connection added %s:%s" % (args[0], args[1]))
|
log.info("New litecoind connection added %s:%s" % (args[0], args[1]))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@admin
|
||||||
|
def refresh_config(self):
|
||||||
|
settings.setup()
|
||||||
|
log.info("Updated Config")
|
||||||
|
return True
|
||||||
|
|
||||||
def authorize(self, worker_name, worker_password):
|
def authorize(self, worker_name, worker_password):
|
||||||
'''Let authorize worker on this connection.'''
|
'''Let authorize worker on this connection.'''
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user