commit d128907bc21e1ca798288ed555b75d63e30ea3ac
parent a606c06b41aea26e594a960a30c0766279ee102d
Author: lash <dev@holbrook.no>
Date: Mon, 14 Mar 2022 21:40:20 +0000
Extract adapter base
Diffstat:
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/chaind/adapters/base.py b/chaind/adapters/base.py
@@ -0,0 +1,10 @@
+# external imports
+from chainqueue import Store as QueueStore
+
+
+class ChaindAdapter:
+
+ def __init__(self, chain_spec, state_store, index_store, counter_store,deserializer, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0):
+ self.deserialize = deserializer
+ self.dispatcher = dispatcher
+ self.store = QueueStore(chain_spec, state_store, index_store, counter_store, cache=cache)
diff --git a/chaind/adapters/fs.py b/chaind/adapters/fs.py
@@ -3,10 +3,7 @@ import logging
# external imports
from chainlib.error import RPCException
-from chainqueue import (
- Status,
- Store as QueueStore,
- )
+from chainqueue import Status
from chainqueue.cache import Cache
from chainqueue.store.fs import (
IndexStore,
@@ -14,19 +11,20 @@ from chainqueue.store.fs import (
)
from shep.store.file import SimpleFileStoreFactory
+# local imports
+from .base import ChaindAdapter
+
logg = logging.getLogger(__name__)
-class ChaindFsAdapter:
+class ChaindFsAdapter(ChaindAdapter):
def __init__(self, chain_spec, path, deserializer, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0, digest_bytes=32):
factory = SimpleFileStoreFactory(path).add
state_store = Status(factory)
index_store = IndexStore(path, digest_bytes=digest_bytes)
counter_store = CounterStore(path)
- self.store = QueueStore(chain_spec, state_store, index_store, counter_store, cache=cache)
- self.deserialize = deserializer
- self.dispatcher = dispatcher
+ super(ChaindFsAdapter, self).__init__(chain_spec, state_store, index_store, counter_store, deserializer, dispatcher, cache=None, pending_retry_threshold=0, error_retry_threshold=0)
def put(self, signed_tx):