Caching working, fetches from mempool every 20 secs

This commit is contained in:
ben
2022-11-25 00:49:31 +00:00
parent e84eedd66f
commit 83e4eb16b1
3 changed files with 91 additions and 101 deletions
+3 -4
View File
@@ -82,7 +82,6 @@ async def get_mempool_info(endPoint: str, gerty) -> Optional[Mempool]:
endpoints = MempoolEndpoint()
url = ""
for endpoint in endpoints:
logger.debug(endpoint)
if endPoint == endpoint[0]:
url = endpoint[1]
row = await db.fetchone("SELECT * FROM gerty.mempool WHERE endpoint = ?", (endPoint,))
@@ -92,13 +91,13 @@ async def get_mempool_info(endPoint: str, gerty) -> Optional[Mempool]:
await db.execute(
"""
INSERT INTO gerty.mempool (
endpoint,
data,
time,
endpoint,
time
)
VALUES (?, ?, ?)
""",
(endPoint, json.dumps(response.json()), int(time.time())),
(json.dumps(response.json()), endPoint, int(time.time())),
)
return response.json()
if int(time.time()) - row.time > 20: