aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hashserv/sqlalchemy.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hashserv/sqlalchemy.py')
-rw-r--r--lib/hashserv/sqlalchemy.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/hashserv/sqlalchemy.py b/lib/hashserv/sqlalchemy.py
index 873547809..0e28d738f 100644
--- a/lib/hashserv/sqlalchemy.py
+++ b/lib/hashserv/sqlalchemy.py
@@ -48,6 +48,7 @@ class UnihashesV3(Base):
__table_args__ = (
UniqueConstraint("method", "taskhash"),
Index("taskhash_lookup_v4", "method", "taskhash"),
+ Index("unihash_lookup_v1", "unihash"),
)
@@ -279,6 +280,16 @@ class Database(object):
)
return map_row(result.first())
+ async def unihash_exists(self, unihash):
+ async with self.db.begin():
+ result = await self._execute(
+ select(UnihashesV3)
+ .where(UnihashesV3.unihash == unihash)
+ .limit(1)
+ )
+
+ return result.first() is not None
+
async def get_outhash(self, method, outhash):
async with self.db.begin():
result = await self._execute(