From 95b317c9233b2c8017c1dc95a79993009d028b4a Mon Sep 17 00:00:00 2001 From: Niclas Blomberg Date: Wed, 4 Sep 2024 14:53:14 +0200 Subject: [PATCH] fix: use geo enum for sql queries --- src/phoenix/demotion_monitor.rs | 4 ++-- src/phoenix/env.rs | 4 ++++ src/phoenix/inclusion_monitor/mod.rs | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/phoenix/demotion_monitor.rs b/src/phoenix/demotion_monitor.rs index e43cec4..61765cc 100644 --- a/src/phoenix/demotion_monitor.rs +++ b/src/phoenix/demotion_monitor.rs @@ -16,12 +16,12 @@ use crate::{ use super::{ checkpoint::{self, CheckpointId}, - env::APP_CONFIG, + env::{Geo, APP_CONFIG}, }; #[derive(Debug, Clone)] pub struct BuilderDemotion { - pub geo: String, + pub geo: Geo, pub builder_pubkey: String, pub builder_id: Option, pub slot: i64, diff --git a/src/phoenix/env.rs b/src/phoenix/env.rs index 4880e0b..8044973 100644 --- a/src/phoenix/env.rs +++ b/src/phoenix/env.rs @@ -87,8 +87,12 @@ fn default_missed_slots_alert_threshold() -> i64 { /// Auction geography #[allow(clippy::upper_case_acronyms)] +#[derive(Debug, Clone, sqlx::Type)] +#[sqlx(type_name = "geo")] pub enum Geo { + #[sqlx(rename = "rbx")] RBX, + #[sqlx(rename = "vin")] VIN, } diff --git a/src/phoenix/inclusion_monitor/mod.rs b/src/phoenix/inclusion_monitor/mod.rs index 6e7526d..f37e659 100644 --- a/src/phoenix/inclusion_monitor/mod.rs +++ b/src/phoenix/inclusion_monitor/mod.rs @@ -29,7 +29,7 @@ use super::{ SendAlert, }, checkpoint::{self, CheckpointId}, - env::APP_CONFIG, + env::{Geo, APP_CONFIG}, }; #[derive(Debug)] @@ -40,7 +40,7 @@ struct DeliveredPayload { inserted_at: DateTime, proposer_pubkey: String, slot: i64, - geo: String, + geo: Geo, } async fn get_delivered_payloads(