From 1a4f30502f1c634fca75de86871e134a0d2a71ae Mon Sep 17 00:00:00 2001 From: Atris Date: Thu, 18 Jul 2024 19:14:22 +0200 Subject: [PATCH] feat: insert root into db too --- crates/bin/pindexer/src/block/block.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/bin/pindexer/src/block/block.rs b/crates/bin/pindexer/src/block/block.rs index 218db28372..585d78f95e 100644 --- a/crates/bin/pindexer/src/block/block.rs +++ b/crates/bin/pindexer/src/block/block.rs @@ -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 ); ", @@ -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?;