Skip to content

Commit

Permalink
fix timestamp updates, instead of reinserting
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbuild3r committed Oct 4, 2023
1 parent 32a3956 commit fdeeedf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 4 additions & 1 deletion schemas/database/010_latest_insertion_timestamp.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
CREATE TABLE latest_insertion_timestamp (
insertion_timestamp TIMESTAMPTZ
Lock char(1) NOT NULL DEFAULT 'X',
insertion_timestamp TIMESTAMPTZ,
constraint PK_T2 PRIMARY KEY (Lock),
constraint CK_T2_Locked CHECK (Lock='X')
);
11 changes: 7 additions & 4 deletions src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,9 @@ impl Database {
pub async fn get_latest_insertion_timestamp(&self) -> Result<Option<DateTime<Utc>>, Error> {
let query = sqlx::query(
r#"
SELECT insertion_timestamp FROM latest_insertion_timestamp
"#,
SELECT insertion_timestamp
FROM latest_insertion_timestamp
WHERE Lock = 'X';"#,
);

let row = self.pool.fetch_optional(query).await?;
Expand Down Expand Up @@ -555,8 +556,10 @@ impl Database {
) -> Result<(), Error> {
let query = sqlx::query(
r#"
INSERT INTO latest_insertion_timestamp (insertion_timestamp)
VALUES ($1)
INSERT INTO latest_insertion_timestamp (Lock, insertion_timestamp)
VALUES ('X', $1)
ON CONFLICT (Lock)
DO UPDATE SET insertion_timestamp = EXCLUDED.insertion_timestamp;
"#,
)
.bind(insertion_timestamp);
Expand Down
4 changes: 1 addition & 3 deletions src/task_monitor/tasks/process_identities.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::sync::Arc;
use std::time::{Duration, SystemTime};
use std::time::Duration;

use anyhow::{Context, Result as AnyhowResult};
use chrono::{DateTime, Utc};
use ethers::types::U256;
use futures_util::TryFutureExt;
use oz_api::data;
use ruint::Uint;
use semaphore::merkle_tree::Proof;
use semaphore::poseidon_tree::Branch;
Expand Down

0 comments on commit fdeeedf

Please sign in to comment.