Skip to content

Commit 1f1c17f

Browse files
fix(fortuna): set last_updated_at correctly, use ms precision (#2937)
* fix(fortuna): set last_updated_at correctly, use ms precision * bump ver
1 parent 314c447 commit 1f1c17f

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

apps/fortuna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "9.1.1"
3+
version = "9.1.2"
44
edition = "2021"
55

66
[lib]

apps/fortuna/src/history.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ impl TryFrom<RequestRow> for RequestStatus {
144144
let network_id = row.network_id as u64;
145145
let provider = row.provider.parse()?;
146146
let sequence = row.sequence as u64;
147-
let created_at = DateTime::from_timestamp(row.created_at, 0)
147+
let created_at = DateTime::from_timestamp_millis(row.created_at)
148148
.ok_or(anyhow::anyhow!("Invalid created_at timestamp"))?;
149-
let last_updated_at = DateTime::from_timestamp(row.last_updated_at, 0)
149+
let last_updated_at = DateTime::from_timestamp_millis(row.last_updated_at)
150150
.ok_or(anyhow::anyhow!("Invalid last_updated_at timestamp"))?;
151151
let request_block_number = row.request_block_number as u64;
152152
let user_random_number = hex::FromHex::from_hex(row.user_random_number)?;
@@ -322,8 +322,8 @@ impl History {
322322
.bind(network_id)
323323
.bind(provider.clone())
324324
.bind(sequence)
325-
.bind(new_status.created_at.timestamp())
326-
.bind(new_status.last_updated_at.timestamp())
325+
.bind(new_status.created_at.timestamp_millis())
326+
.bind(new_status.last_updated_at.timestamp_millis())
327327
.bind("Pending")
328328
.bind(block_number)
329329
.bind(request_tx_hash.clone())
@@ -354,7 +354,7 @@ impl History {
354354
let callback_gas_used: String = callback_gas_used.to_string();
355355
let result = sqlx::query("UPDATE request SET state = $1, last_updated_at = $2, reveal_block_number = $3, reveal_tx_hash = $4, provider_random_number = $5, gas_used = $6, callback_failed = $7, callback_return_value = $8, callback_gas_used = $9 WHERE network_id = $10 AND sequence = $11 AND provider = $12 AND request_tx_hash = $13")
356356
.bind("Completed")
357-
.bind(new_status.last_updated_at.timestamp())
357+
.bind(new_status.last_updated_at.timestamp_millis())
358358
.bind(reveal_block_number)
359359
.bind(reveal_tx_hash)
360360
.bind(provider_random_number)
@@ -383,7 +383,7 @@ impl History {
383383
.map(|provider_random_number| provider_random_number.encode_hex());
384384
sqlx::query("UPDATE request SET state = $1, last_updated_at = $2, info = $3, provider_random_number = $4 WHERE network_id = $5 AND sequence = $6 AND provider = $7 AND request_tx_hash = $8 AND state = 'Pending'")
385385
.bind("Failed")
386-
.bind(new_status.last_updated_at.timestamp())
386+
.bind(new_status.last_updated_at.timestamp_millis())
387387
.bind(reason)
388388
.bind(provider_random_number)
389389
.bind(network_id)
@@ -553,8 +553,8 @@ impl<'a> RequestQueryBuilder<'a> {
553553

554554
// Now bind all parameters in order
555555
let mut query = sqlx::query_as::<_, RequestRow>(&sql)
556-
.bind(self.min_timestamp.timestamp())
557-
.bind(self.max_timestamp.timestamp());
556+
.bind(self.min_timestamp.timestamp_millis())
557+
.bind(self.max_timestamp.timestamp_millis());
558558

559559
match &self.search {
560560
Some(SearchField::TxHash(tx_hash)) => {
@@ -635,8 +635,8 @@ impl<'a> RequestQueryBuilder<'a> {
635635

636636
// Now bind all parameters in order
637637
let mut query = sqlx::query_scalar::<_, i64>(&sql)
638-
.bind(self.min_timestamp.timestamp())
639-
.bind(self.max_timestamp.timestamp());
638+
.bind(self.min_timestamp.timestamp_millis())
639+
.bind(self.max_timestamp.timestamp_millis());
640640

641641
match &self.search {
642642
Some(SearchField::TxHash(tx_hash)) => {

apps/fortuna/src/keeper/process_event.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ pub async fn process_event_with_backoff(
181181
.get_or_create(&account_label)
182182
.inc();
183183

184+
status.last_updated_at = chrono::Utc::now();
184185
match success {
185186
Ok(result) => {
186187
status.state = RequestEntryState::Completed {

0 commit comments

Comments
 (0)