|
@ -30,12 +30,7 @@ class Daemon(util.LoggedClass): |
|
|
|
|
|
|
|
|
def __init__(self, urls): |
|
|
def __init__(self, urls): |
|
|
super().__init__() |
|
|
super().__init__() |
|
|
if not urls: |
|
|
self.set_urls(urls) |
|
|
raise DaemonError('no daemon URLs provided') |
|
|
|
|
|
for url in urls: |
|
|
|
|
|
self.logger.info('daemon at {}'.format(self.logged_url(url))) |
|
|
|
|
|
self.urls = urls |
|
|
|
|
|
self.url_index = 0 |
|
|
|
|
|
self._height = None |
|
|
self._height = None |
|
|
self._mempool_hashes = set() |
|
|
self._mempool_hashes = set() |
|
|
self.mempool_refresh_event = asyncio.Event() |
|
|
self.mempool_refresh_event = asyncio.Event() |
|
@ -43,6 +38,15 @@ class Daemon(util.LoggedClass): |
|
|
# See DEFAULT_HTTP_WORKQUEUE in bitcoind, which is typically 16 |
|
|
# See DEFAULT_HTTP_WORKQUEUE in bitcoind, which is typically 16 |
|
|
self.workqueue_semaphore = asyncio.Semaphore(value=10) |
|
|
self.workqueue_semaphore = asyncio.Semaphore(value=10) |
|
|
|
|
|
|
|
|
|
|
|
def set_urls(self, urls): |
|
|
|
|
|
'''Set the URLS to the given list, and switch to the first one.''' |
|
|
|
|
|
if not urls: |
|
|
|
|
|
raise DaemonError('no daemon URLs provided') |
|
|
|
|
|
for url in urls: |
|
|
|
|
|
self.logger.info('daemon at {}'.format(self.logged_url(url))) |
|
|
|
|
|
self.urls = urls |
|
|
|
|
|
self.url_index = 0 |
|
|
|
|
|
|
|
|
async def _send(self, payload, processor): |
|
|
async def _send(self, payload, processor): |
|
|
'''Send a payload to be converted to JSON. |
|
|
'''Send a payload to be converted to JSON. |
|
|
|
|
|
|
|
|