Implement strict get match
This commit is contained in:
parent
c4caab6a3a
commit
3880249683
@ -36,12 +36,13 @@ class Store:
|
|||||||
return self.index_store.get(k)
|
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 = []
|
hashes = []
|
||||||
i = 0
|
i = 0
|
||||||
for k in self.state_store.list(state):
|
for k in self.state_store.list(state):
|
||||||
if state_exact:
|
item_state = self.state_store.state(k)
|
||||||
if self.state_store.state(k) & state == state:
|
if strict:
|
||||||
|
if item_state & state != item_state:
|
||||||
continue
|
continue
|
||||||
hashes.append(k)
|
hashes.append(k)
|
||||||
return hashes
|
return hashes
|
||||||
|
@ -59,6 +59,8 @@ class TestShep(TestShepBase):
|
|||||||
txs = self.store.list(state=self.store.IN_NETWORK)
|
txs = self.store.list(state=self.store.IN_NETWORK)
|
||||||
self.assertEqual(len(txs), 2)
|
self.assertEqual(len(txs), 2)
|
||||||
|
|
||||||
|
txs = self.store.list(state=self.store.IN_NETWORK, strict=True)
|
||||||
|
self.assertEqual(len(txs), 1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user