chainqueue

Blockchain transaction queue control
Log | Files | Refs | LICENSE

commit 532ff230b457e4a172f20f387083f13d1641ba6a
parent f7c09acfe2cabdd53aec9df2f997ee8a9646ab0c
Author: lash <dev@holbrook.no>
Date:   Sun,  1 May 2022 06:44:33 +0000

Remove race waits (defer to client layer)

Diffstat:
MCHANGELOG | 9+++++++++
Mchainqueue/error.py | 6------
Mchainqueue/store/base.py | 37++++++++++++++-----------------------
Msetup.cfg | 2+-
4 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,12 @@ +- 0.1.6 + * Sort upcoming queue item chronologically + * Add unit testing for upcoming query method +- 0.1.5 + * Add reserved state check method +- 0.1.4 + * Dependency cleanups +- 0.1.3 + * Add CLI args and config handling, settings object - 0.1.2 * Add CLI inspection tools - 0.1.1 diff --git a/chainqueue/error.py b/chainqueue/error.py @@ -24,12 +24,6 @@ class CacheIntegrityError(ChainQueueException): pass -class BackendIntegrityError(ChainQueueException): - """Raised when queue backend has invalid state - """ - pass - - class DuplicateTxError(ChainQueueException): """Backend already knows transaction """ diff --git a/chainqueue/store/base.py b/chainqueue/store/base.py @@ -7,10 +7,7 @@ import time # local imports from chainqueue.cache import CacheTx from chainqueue.entry import QueueEntry -from chainqueue.error import ( - NotLocalTxError, - BackendIntegrityError, - ) +from chainqueue.error import NotLocalTxError from chainqueue.enum import ( StatusBits, all_errors, @@ -32,8 +29,6 @@ all_local_errors = all_errors() - StatusBits.NETWORK_ERROR re_u = r'^[^_][_A-Z]+$' class Store: - race_delay = 0.1 - def __init__(self, chain_spec, state_store, index_store, counter, cache=None): self.chain_spec = chain_spec self.cache = cache @@ -56,16 +51,13 @@ class Store: setattr(self, v, getattr(self.state_store, v)) sync_err = None - for i in range(2): - try: - self.state_store.sync() - except Exception as e: - sync_err = e - time.sleep(self.race_delay) - continue + try: + self.state_store.sync() + except Exception as e: + sync_err = e if sync_err != None: - raise BackendIntegrityError(sync_err) + raise FileNotFoundError(sync_err) def put(self, v, cache_adapter=CacheTx): @@ -84,16 +76,15 @@ class Store: def get(self, k): v = None - for i in range(2): - s = self.index_store.get(k) - try: - self.state_store.sync() - v = self.state_store.get(s) - except FileNotFoundError: - continue - break + s = self.index_store.get(k) + err = None + try: + self.state_store.sync() + v = self.state_store.get(s) + except FileNotFoundError as e: + err = e if v == None: - raise NotLocalTxError(k) + raise NotLocalTxError('could not find tx {}: {}'.format(k, err)) return (s, v,) diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainqueue -version = 0.1.6 +version = 0.1.7 description = Generic blockchain transaction queue control author = Louis Holbrook author_email = dev@holbrook.no