diff --git a/chainqueue/cache.py b/chainqueue/cache.py index 116230b..8ce0120 100644 --- 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 CacheFilter: + + 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 __init__(self, translator): - self.translator = translator - - - def put_serialized(self, chain_spec, signed_tx): - cache_tx = self.translate(chain_spec, signed_tx) - return self.put(chain_spec, cache_tx) - - 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 similarity index 100% rename from tests/chainqueue_base.py rename to tests/old/chainqueue_base.py diff --git a/tests/test_basic.py b/tests/old/test_basic.py similarity index 100% rename from tests/test_basic.py rename to tests/old/test_basic.py diff --git a/tests/test_fs.py b/tests/old/test_fs.py similarity index 100% rename from tests/test_fs.py rename to tests/old/test_fs.py diff --git a/tests/test_fs_entry.py b/tests/old/test_fs_entry.py similarity index 100% rename from tests/test_fs_entry.py rename to tests/old/test_fs_entry.py diff --git a/tests/test_helo.py b/tests/old/test_helo.py similarity index 100% rename from tests/test_helo.py rename to tests/old/test_helo.py diff --git a/tests/test_otx.py b/tests/old/test_otx.py similarity index 100% rename from tests/test_otx.py rename to tests/old/test_otx.py diff --git a/tests/test_otx_status_log.py b/tests/old/test_otx_status_log.py similarity index 100% rename from tests/test_otx_status_log.py rename to tests/old/test_otx_status_log.py diff --git a/tests/test_query.py b/tests/old/test_query.py similarity index 100% rename from tests/test_query.py rename to tests/old/test_query.py diff --git a/tests/test_tx_cache.py b/tests/old/test_tx_cache.py similarity index 100% rename from tests/test_tx_cache.py rename to tests/old/test_tx_cache.py