Skip to content

Commit

Permalink
feat: insert root into db too
Browse files Browse the repository at this point in the history
  • Loading branch information
vacekj committed Jul 19, 2024
1 parent e041c49 commit 9e7985b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/bin/pindexer/src/block/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl AppView for Block {
CREATE TABLE IF NOT EXISTS block_details (
id SERIAL PRIMARY KEY,
root BYTEA NOT NULL,
height BYTEA NOT NULL,
height INT8 NOT NULL,
timestamp TIMESTAMPTZ NOT NULL
);
",
Expand All @@ -42,12 +42,13 @@ CREATE TABLE IF NOT EXISTS block_details (

sqlx::query(
"
INSERT INTO block_details (height, timestamp)
VALUES ($1, $2)
INSERT INTO block_details (height, timestamp, root)
VALUES ($1, $2, $3)
",
)
.bind(&pe.height)
.bind(pe.height as i64)
.bind(DateTime::from_timestamp(timestamp.seconds, timestamp.nanos as u32).unwrap())
.bind(pe.root.unwrap().inner)
.execute(dbtx.as_mut())
.await?;

Expand Down

0 comments on commit 9e7985b

Please sign in to comment.