Skip to content

Commit 26baa4b

Browse files
fix(kms-connector): use numeric for last block (#1292)
1 parent 8cee8fb commit 26baa4b

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

kms-connector/.sqlx/query-4d560e50c6fda74882a8dafbb767abbbd95e6fa06f732fce2fbf857470c3e4c1.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kms-connector/connector-db/migrations/20251104142103_add_last_block_polled.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ END $$;
1515

1616
CREATE TABLE IF NOT EXISTS last_block_polled (
1717
event_type event_type NOT NULL,
18-
block_number BYTEA,
18+
block_number BIGINT,
1919
update_at TIMESTAMP NOT NULL DEFAULT NOW(),
2020
PRIMARY KEY (event_type)
2121
);

kms-connector/crates/gw-listener/src/core/gw_listener.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,13 @@ where
251251
.bind(event_type)
252252
.fetch_one(&self.db_pool)
253253
.await?
254-
.try_get::<Option<Vec<u8>>, _>("block_number")?;
254+
.try_get::<Option<i64>, _>("block_number")?;
255255

256-
let Some(block_number_bytes) = query_result else {
256+
let Some(block_number) = query_result else {
257257
info!("No block number stored in DB yet for {event_type}");
258258
return Ok(None);
259259
};
260-
261-
let block_number = block_number_bytes
262-
.try_into()
263-
.map(u64::from_le_bytes)
264-
.map_err(|b| anyhow!("Couldn't convert {b:?} into u64"))?;
265-
Ok(Some(block_number))
260+
Ok(Some(block_number as u64))
266261
}
267262
}
268263

kms-connector/crates/gw-listener/src/core/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub async fn update_last_block_polled(
210210
"UPDATE last_block_polled SET block_number = $2 \
211211
WHERE event_type = $1 AND (block_number IS NULL OR block_number < $2)",
212212
event_type as EventType,
213-
last_block_polled.map(|n| n.to_le_bytes().to_vec()),
213+
last_block_polled.map(|n| n as i64),
214214
)
215215
.execute(db_pool)
216216
.await?;

0 commit comments

Comments
 (0)