chainqueue

Blockchain transaction queue control
Log | Files | Refs | LICENSE

commit 68f50246d2c729428b477fda07b29f50df9370d6
parent bd77706d1a2135467cc190ba036b9c1c4cc33396
Author: lash <dev@holbrook.no>
Date:   Sat, 12 Mar 2022 09:14:23 +0000

Add cache interface methods, move old tests

Diffstat:
Mchainqueue/cache.py | 37++++++++++++++++++++++++++++++-------
Rtests/chainqueue_base.py -> tests/old/chainqueue_base.py | 0
Rtests/test_basic.py -> tests/old/test_basic.py | 0
Rtests/test_fs.py -> tests/old/test_fs.py | 0
Rtests/test_fs_entry.py -> tests/old/test_fs_entry.py | 0
Rtests/test_helo.py -> tests/old/test_helo.py | 0
Rtests/test_otx.py -> tests/old/test_otx.py | 0
Rtests/test_otx_status_log.py -> tests/old/test_otx_status_log.py | 0
Rtests/test_query.py -> tests/old/test_query.py | 0
Rtests/test_tx_cache.py -> tests/old/test_tx_cache.py | 0
10 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/chainqueue/cache.py b/chainqueue/cache.py @@ -1,3 +1,7 @@ +# standard imports +import enum + + class CacheTx: def __init__(self): @@ -48,21 +52,40 @@ class CacheTokenTx(CacheTx): self.v_dst_value = None +class CacheSort(enum.Enum): + DATE = 1 + NONCE = 2 -class Cache: - def __init__(self, translator): - self.translator = translator - +class CacheFilter: - def put_serialized(self, chain_spec, signed_tx): - cache_tx = self.translate(chain_spec, signed_tx) - return self.put(chain_spec, cache_tx) + def __init__(self, senders=None, recipients=None, nonce=None, before=None, after=None, sort=CacheSort.DATE, reverse=False): + self.senders = senders + self.recipients = recipients + self.nonce = nonce + self.before = before + self.after = after + self.sort = sort + self.reverse = reverse +class Cache: + def put(self, chain_spec, cache_tx): raise NotImplementedError() def get(self, chain_spec, tx_hash): raise NotImplementedError() + + + def by_nonce(self, cache_filter): + raise NotImplementedError() + + + def by_date(self, cache_filter=None): + raise NotImplementedError() + + + def count(self, cache_filter=None): + raise NotImplementedError() diff --git a/tests/chainqueue_base.py b/tests/old/chainqueue_base.py diff --git a/tests/test_basic.py b/tests/old/test_basic.py diff --git a/tests/test_fs.py b/tests/old/test_fs.py diff --git a/tests/test_fs_entry.py b/tests/old/test_fs_entry.py diff --git a/tests/test_helo.py b/tests/old/test_helo.py diff --git a/tests/test_otx.py b/tests/old/test_otx.py diff --git a/tests/test_otx_status_log.py b/tests/old/test_otx_status_log.py diff --git a/tests/test_query.py b/tests/old/test_query.py diff --git a/tests/test_tx_cache.py b/tests/old/test_tx_cache.py