diff --git a/db.py b/db.py index f1c5af06..2c3e89d2 100644 --- a/db.py +++ b/db.py @@ -928,26 +928,26 @@ async def _save_block(self, block: Block): "VALUES (%s, %s, %s)", (vertex_db_id, str(signature), sig_index) ) - - prev_cert_ids = certificate.batch_header.previous_certificate_ids - await cur.execute( - "SELECT v.id, batch_certificate_id FROM dag_vertex v " - "JOIN UNNEST(%s::text[]) WITH ORDINALITY c(id, ord) ON v.batch_certificate_id = c.id " - "ORDER BY ord", - (list(map(str, prev_cert_ids)),) - ) - res = await cur.fetchall() + # + # prev_cert_ids = certificate.batch_header.previous_certificate_ids + # await cur.execute( + # "SELECT v.id, batch_certificate_id FROM dag_vertex v " + # "JOIN UNNEST(%s::text[]) WITH ORDINALITY c(id, ord) ON v.batch_certificate_id = c.id " + # "ORDER BY ord", + # (list(map(str, prev_cert_ids)),) + # ) + # res = await cur.fetchall() # temp allow # if len(res) != len(prev_cert_ids): # raise RuntimeError("dag referenced unknown previous certificate") - prev_vertex_db_ids = {x["batch_certificate_id"]: x["id"] for x in res} - adj_copy_data: list[tuple[int, int, int]] = [] - for prev_index, prev_cert_id in enumerate(prev_cert_ids): - if str(prev_cert_id) in prev_vertex_db_ids: - adj_copy_data.append((vertex_db_id, prev_vertex_db_ids[str(prev_cert_id)], prev_index)) - async with cur.copy("COPY dag_vertex_adjacency (vertex_id, previous_vertex_id, index) FROM STDIN") as copy: - for row in adj_copy_data: - await copy.write_row(row) + # prev_vertex_db_ids = {x["batch_certificate_id"]: x["id"] for x in res} + # adj_copy_data: list[tuple[int, int, int]] = [] + # for prev_index, prev_cert_id in enumerate(prev_cert_ids): + # if str(prev_cert_id) in prev_vertex_db_ids: + # adj_copy_data.append((vertex_db_id, prev_vertex_db_ids[str(prev_cert_id)], prev_index)) + # async with cur.copy("COPY dag_vertex_adjacency (vertex_id, previous_vertex_id, index) FROM STDIN") as copy: + # for row in adj_copy_data: + # await copy.write_row(row) tid_copy_data: list[tuple[int, str, int, Optional[str], Optional[str]]] = [] for tid_index, transmission_id in enumerate(certificate.batch_header.transmission_ids):