本文整理汇总了Python中stratum.pubsub.Pubsub.get_subscription方法的典型用法代码示例。如果您正苦于以下问题:Python Pubsub.get_subscription方法的具体用法?Python Pubsub.get_subscription怎么用?Python Pubsub.get_subscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stratum.pubsub.Pubsub
的用法示例。
在下文中一共展示了Pubsub.get_subscription方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: subscribe
# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import get_subscription [as 别名]
def subscribe(self, *args):
connection = self.connection_ref()
session = connection.get_session()
if session.get('extranonce1'):
# Already subscribed
subs1 = Pubsub.get_subscription(connection, DifficultySubscription.event)
subs2 = Pubsub.get_subscription(connection, MiningSubscription.event)
extranonce1_hex = binascii.hexlify(session['extranonce1'])
extranonce2_size = Interfaces.template_registry.extranonce2_size
log.warning('Already subscribed')
return (((subs1.event, subs1.get_key()), (subs2.event, subs2.get_key())),) + \
(extranonce1_hex, extranonce2_size)
extranonce1 = Interfaces.template_registry.get_new_extranonce1()
extranonce2_size = Interfaces.template_registry.extranonce2_size
extranonce1_hex = binascii.hexlify(extranonce1)
session['extranonce1'] = extranonce1
session['subscribed_at'] = posix_time()
# Don't accept job_id if job_id < min_job_id
session['min_job_id'] = 0
session['client_sw'] = self._get_client_sw(*args)
subs1 = Pubsub.subscribe(connection, DifficultySubscription())[0]
subs2 = Pubsub.subscribe(connection, MiningSubscription())[0]
Interfaces.reporter.new_subscription(session)
return ((subs1, subs2),) + (extranonce1_hex, extranonce2_size)
示例2: _on_worker_refresh
# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import get_subscription [as 别名]
def _on_worker_refresh(self, facts):
'''
Callback passed to WorkerDB's refresh method for being
notified about refreshed workers. We update the memory worker
data appropriately.
See WorkerDB.refresh_from_source for details about passed
'facts' dictionary.
'''
worker_name = facts['worker_name']
# The worker is not in memory, there is nothing to be updated
worker = self.workers.get(worker_name)
if not worker:
return
# We should update the id and password unconditionally
worker['worker_id'] = facts['worker_id']
# Suggested difficulty has been changed ..
if worker['difficulty_suggested'] != facts['difficulty_suggested']:
# Assign the new suggested difficulty
worker['difficulty_suggested'] = facts['difficulty_suggested']
# .. so let's poke DifficultySubscription and let it
# recalculate difficulties
for conn in worker['connections'].keys():
diff_sub = Pubsub.get_subscription(conn, DifficultySubscription.event)
diff_sub.recalculate_difficulty(worker_name)
示例3: print_subs
# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import get_subscription [as 别名]
def print_subs(cls):
c = Pubsub.get_subscription_count(cls.event)
log.info(c)
for subs in Pubsub.iterate_subscribers(cls.event):
s = Pubsub.get_subscription(
subs.connection_ref(),
cls.event,
key=None)
log.info(s)
示例4: emit_single_before_mining_notify
# 需要导入模块: from stratum.pubsub import Pubsub [as 别名]
# 或者: from stratum.pubsub.Pubsub import get_subscription [as 别名]
def emit_single_before_mining_notify(self, connection):
try:
# Get the related subscription if there is some already
diff_subs = Pubsub.get_subscription(connection, DifficultySubscription.event)
# Plan the emission
diff_subs.plan_single_emission()
except PubsubException:
# Connection is not subscribed for mining yet
pass