Daemon constructor passed coin and URLs directly

This commit is contained in:
Neil Booth 2018-08-12 23:44:18 +09:00
parent a108817dd4
commit 13a8b62d8c
2 changed files with 8 additions and 6 deletions

View File

@ -92,9 +92,11 @@ class Controller(ServerBase):
self.logger.info(f'reorg limit is {env.reorg_limit:,d} blocks')
notifications = Notifications()
daemon = env.coin.DAEMON(env)
db = DB(env)
Daemon = env.coin.DAEMON
BlockProcessor = env.coin.BLOCK_PROCESSOR
daemon = Daemon(env.coin, env.daemon_url)
db = DB(env)
bp = BlockProcessor(env, db, daemon, notifications)
# Set ourselves up to implement the MemPoolAPI

View File

@ -37,14 +37,14 @@ class Daemon(object):
class DaemonWarmingUpError(Exception):
'''Raised when the daemon returns an error in its results.'''
def __init__(self, env):
def __init__(self, coin, urls, max_workqueue=10):
self.coin = coin
self.logger = class_logger(__name__, self.__class__.__name__)
self.coin = env.coin
self.set_urls(env.coin.daemon_urls(env.daemon_url))
self.set_urls(coin.daemon_urls(urls))
self._height = None
# Limit concurrent RPC calls to this number.
# See DEFAULT_HTTP_WORKQUEUE in bitcoind, which is typically 16
self.workqueue_semaphore = asyncio.Semaphore(value=10)
self.workqueue_semaphore = asyncio.Semaphore(value=max_workqueue)
self.down = False
self.last_error_time = 0
self.req_id = 0