Skip to content

Commit

Permalink
fix: set timestamp from code instead of PG
Browse files Browse the repository at this point in the history
To please sequelize...

Signed-off-by: Alexis Asseman <[email protected]>
  • Loading branch information
aasseman committed Feb 21, 2024
1 parent 6687215 commit b5f36ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions migrations/20230915230734_tap_ravs.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ CREATE TABLE IF NOT EXISTS scalar_tap_ravs (
PRIMARY KEY (allocation_id, sender_address),

-- To make indexer-agent's sequelize happy
createdAt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
createdAt TIMESTAMP WITH TIME ZONE,
updatedAt TIMESTAMP WITH TIME ZONE
);

-- This table is used to store failed RAV requests.
Expand Down
1 change: 1 addition & 0 deletions tap-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sqlx = { version = "0.7.2", features = [
"runtime-tokio",
"bigdecimal",
"rust_decimal",
"chrono",
] }
tap_aggregator = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", branch = "aasseman/tap_core_0_7_0_fix_toolshed_dep" }
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", branch = "aasseman/tap_core_0_7_0_fix_toolshed_dep" }
Expand Down
11 changes: 7 additions & 4 deletions tap-agent/src/tap/rav_storage_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bigdecimal::num_bigint::{BigInt, ToBigInt};
use bigdecimal::ToPrimitive;
use ethers::types::Signature;
use open_fastrlp::{Decodable, Encodable};
use sqlx::types::BigDecimal;
use sqlx::types::{chrono, BigDecimal};
use sqlx::PgPool;
use tap_core::adapters::rav_storage_adapter::RAVStorageAdapter as RAVStorageAdapterTrait;
use tap_core::receipt_aggregate_voucher::ReceiptAggregateVoucher;
Expand Down Expand Up @@ -45,21 +45,24 @@ impl RAVStorageAdapterTrait for RAVStorageAdapter {
signature,
allocation_id,
timestamp_ns,
value_aggregate
value_aggregate,
createdAt,
updatedAt
)
VALUES ($1, $2, $3, $4, $5)
VALUES ($1, $2, $3, $4, $5, $6, $6)
ON CONFLICT (allocation_id, sender_address)
DO UPDATE SET
signature = $2,
timestamp_ns = $4,
value_aggregate = $5,
updatedAt = default
updatedAt = $6
"#,
self.sender.encode_hex::<String>(),
signature_bytes,
self.allocation_id.encode_hex::<String>(),
BigDecimal::from(rav.message.timestamp_ns),
BigDecimal::from(BigInt::from(rav.message.value_aggregate)),
chrono::Utc::now()
)
.execute(&self.pgpool)
.await
Expand Down

0 comments on commit b5f36ba

Please sign in to comment.