chaind/chaind/adapters/base.py

28 lines
921 B
Python
Raw Normal View History

# standard imports
import logging
2022-05-01 09:55:51 +02:00
import time
2022-03-14 22:40:20 +01:00
# external imports
from chainqueue import Store as QueueStore
# local imports
2022-05-02 11:59:13 +02:00
from chaind.lock import StoreLock
logg = logging.getLogger(__name__)
2022-03-14 22:40:20 +01:00
class ChaindAdapter:
def __init__(self, chain_spec, state_store, index_store, counter_store, cache_adapter, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0, store_sync=True):
self.cache_adapter = cache_adapter
2022-03-14 22:40:20 +01:00
self.dispatcher = dispatcher
2022-05-02 11:59:13 +02:00
store_lock = StoreLock()
while True:
try:
self.store = QueueStore(chain_spec, state_store, index_store, counter_store, cache=cache, sync=store_sync)
break
except FileNotFoundError as e:
2022-05-01 09:55:51 +02:00
logg.debug('queuestore instantiation failed, possible race condition (will try again): {}'.format(e))
2022-05-02 11:59:13 +02:00
store_lock.again()
continue