commit 3880249683efe79837833ee547ebbfbf4f898a41
parent c4caab6a3a7a7e289f7e5ea6afbda63d281bb776
Author: lash <dev@holbrook.no>
Date: Fri, 11 Mar 2022 19:43:00 +0000
Implement strict get match
Diffstat:
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/chainqueue/store.py b/chainqueue/store.py
@@ -36,12 +36,13 @@ class Store:
return self.index_store.get(k)
- def list(self, state=0, limit=4096, state_exact=False):
+ def list(self, state=0, limit=4096, strict=False):
hashes = []
i = 0
for k in self.state_store.list(state):
- if state_exact:
- if self.state_store.state(k) & state == state:
+ item_state = self.state_store.state(k)
+ if strict:
+ if item_state & state != item_state:
continue
hashes.append(k)
return hashes
diff --git a/tests/test_entry.py b/tests/test_entry.py
@@ -59,6 +59,8 @@ class TestShep(TestShepBase):
txs = self.store.list(state=self.store.IN_NETWORK)
self.assertEqual(len(txs), 2)
+ txs = self.store.list(state=self.store.IN_NETWORK, strict=True)
+ self.assertEqual(len(txs), 1)
if __name__ == '__main__':