Extract adapter base
This commit is contained in:
parent
a606c06b41
commit
d128907bc2
10
chaind/adapters/base.py
Normal file
10
chaind/adapters/base.py
Normal file
@ -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)
|
@ -3,10 +3,7 @@ import logging
|
|||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from chainlib.error import RPCException
|
from chainlib.error import RPCException
|
||||||
from chainqueue import (
|
from chainqueue import Status
|
||||||
Status,
|
|
||||||
Store as QueueStore,
|
|
||||||
)
|
|
||||||
from chainqueue.cache import Cache
|
from chainqueue.cache import Cache
|
||||||
from chainqueue.store.fs import (
|
from chainqueue.store.fs import (
|
||||||
IndexStore,
|
IndexStore,
|
||||||
@ -14,19 +11,20 @@ from chainqueue.store.fs import (
|
|||||||
)
|
)
|
||||||
from shep.store.file import SimpleFileStoreFactory
|
from shep.store.file import SimpleFileStoreFactory
|
||||||
|
|
||||||
|
# local imports
|
||||||
|
from .base import ChaindAdapter
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
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):
|
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
|
factory = SimpleFileStoreFactory(path).add
|
||||||
state_store = Status(factory)
|
state_store = Status(factory)
|
||||||
index_store = IndexStore(path, digest_bytes=digest_bytes)
|
index_store = IndexStore(path, digest_bytes=digest_bytes)
|
||||||
counter_store = CounterStore(path)
|
counter_store = CounterStore(path)
|
||||||
self.store = QueueStore(chain_spec, state_store, index_store, counter_store, cache=cache)
|
super(ChaindFsAdapter, self).__init__(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
|
|
||||||
|
|
||||||
|
|
||||||
def put(self, signed_tx):
|
def put(self, signed_tx):
|
||||||
|
Loading…
Reference in New Issue
Block a user