Skip to content

Commit aa0d3e6

Browse files
fix: remove s3_bucket_name constant (#634)
1 parent 1044de8 commit aa0d3e6

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

  • batcher/aligned-batcher/src

batcher/aligned-batcher/src/lib.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
extern crate core;
22

3+
use dotenv::dotenv;
4+
35
use std::borrow::Cow;
6+
use std::env;
47
use std::net::SocketAddr;
58
use std::sync::Arc;
69
use std::time::Duration;
@@ -42,10 +45,9 @@ pub mod sp1;
4245
pub mod types;
4346
mod zk_utils;
4447

45-
const S3_BUCKET_NAME: &str = "storage.alignedlayer.com";
46-
4748
pub struct Batcher {
4849
s3_client: S3Client,
50+
s3_bucket_name: String,
4951
eth_ws_provider: Provider<Ws>,
5052
service_manager: AlignedLayerServiceManager,
5153
payment_service: BatcherPaymentService,
@@ -61,6 +63,10 @@ pub struct Batcher {
6163

6264
impl Batcher {
6365
pub async fn new(config_file: String) -> Self {
66+
dotenv().ok();
67+
let s3_bucket_name =
68+
env::var("AWS_BUCKET_NAME").expect("AWS_BUCKET_NAME not found in environment");
69+
6470
let s3_client = s3::create_client().await;
6571

6672
let config = ConfigFromYaml::new(config_file);
@@ -107,6 +113,7 @@ impl Batcher {
107113

108114
Self {
109115
s3_client,
116+
s3_bucket_name,
110117
eth_ws_provider,
111118
service_manager,
112119
payment_service,
@@ -440,15 +447,20 @@ impl Batcher {
440447
let file_name = batch_merkle_root_hex.clone() + ".json";
441448

442449
info!("Uploading batch to S3...");
443-
s3::upload_object(&s3_client, S3_BUCKET_NAME, batch_bytes.to_vec(), &file_name)
444-
.await
445-
.expect("Failed to upload object to S3");
450+
s3::upload_object(
451+
&s3_client,
452+
&self.s3_bucket_name,
453+
batch_bytes.to_vec(),
454+
&file_name,
455+
)
456+
.await
457+
.expect("Failed to upload object to S3");
446458

447459
info!("Batch sent to S3 with name: {}", file_name);
448460

449461
info!("Uploading batch to contract");
450462
let payment_service = &self.payment_service;
451-
let batch_data_pointer = "https://".to_owned() + S3_BUCKET_NAME + "/" + &file_name;
463+
let batch_data_pointer = "https://".to_owned() + &self.s3_bucket_name + "/" + &file_name;
452464

453465
let num_proofs_in_batch = submitter_addresses.len();
454466

0 commit comments

Comments
 (0)