Skip to content

Commit

Permalink
disable adjacency for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
HarukaMa committed Dec 1, 2023
1 parent 11e133f commit be342b0
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit be342b0

Please sign in to comment.