Skip to content

Commit b9cf0fd

Browse files
committed
chore(coprocessor): use DatabaseURL in txn-sender
1 parent 6130f46 commit b9cf0fd

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

coprocessor/fhevm-engine/transaction-sender/src/bin/transaction_sender.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use transaction_sender::{
2020

2121
use fhevm_engine_common::{
2222
metrics_server,
23-
telemetry::{self, MetricsConfig},
23+
telemetry::{self, utils::DatabaseURL, MetricsConfig},
2424
};
2525
use humantime::parse_duration;
2626

@@ -52,7 +52,7 @@ struct Conf {
5252
private_key: Option<String>,
5353

5454
#[arg(short, long)]
55-
database_url: Option<String>,
55+
database_url: Option<DatabaseURL>,
5656

5757
#[arg(long, default_value = "10")]
5858
database_pool_size: u32,
@@ -229,7 +229,9 @@ async fn main() -> anyhow::Result<()> {
229229
let wallet = EthereumWallet::new(abstract_signer.clone());
230230
let database_url = match conf.database_url.clone() {
231231
Some(url) => url,
232-
None => std::env::var("DATABASE_URL").context("DATABASE_URL is undefined")?,
232+
None => std::env::var("DATABASE_URL")
233+
.context("DATABASE_URL is undefined")?
234+
.into(),
233235
};
234236

235237
let provider = loop {

coprocessor/fhevm-engine/transaction-sender/src/config.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use std::time::Duration;
22

3+
use fhevm_engine_common::utils::DatabaseURL;
4+
35
#[derive(Clone, Debug)]
46
pub struct ConfigSettings {
5-
pub database_url: String,
7+
pub database_url: DatabaseURL,
68
pub database_pool_size: u32,
79

810
pub verify_proof_resp_db_channel: String,
@@ -46,8 +48,7 @@ pub struct ConfigSettings {
4648
impl Default for ConfigSettings {
4749
fn default() -> Self {
4850
Self {
49-
database_url: std::env::var("DATABASE_URL")
50-
.unwrap_or("postgres://postgres:postgres@localhost/coprocessor".to_owned()),
51+
database_url: DatabaseURL::default(),
5152
database_pool_size: 10,
5253
verify_proof_resp_db_channel: "event_zkpok_computed".to_owned(),
5354
add_ciphertexts_db_channel: "event_ciphertexts_uploaded".to_owned(),

coprocessor/fhevm-engine/transaction-sender/src/transaction_sender.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<P: Provider<Ethereum> + Clone + 'static> TransactionSender<P> {
3737
) -> anyhow::Result<Self> {
3838
let db_pool = sqlx::postgres::PgPoolOptions::new()
3939
.max_connections(conf.database_pool_size)
40-
.connect(&conf.database_url)
40+
.connect(conf.database_url.as_str())
4141
.await?;
4242

4343
let operations: Vec<Arc<dyn ops::TransactionOperation<P>>> = vec![

coprocessor/fhevm-engine/transaction-sender/tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl TestEnvironment {
8181

8282
let db_pool = PgPoolOptions::new()
8383
.max_connections(1)
84-
.connect(&conf.database_url)
84+
.connect(conf.database_url.as_str())
8585
.await?;
8686

8787
Self::truncate_tables(

0 commit comments

Comments
 (0)