11extern crate core;
22
3+ use dotenv:: dotenv;
4+
35use std:: borrow:: Cow ;
6+ use std:: env;
47use std:: net:: SocketAddr ;
58use std:: sync:: Arc ;
69use std:: time:: Duration ;
@@ -42,10 +45,9 @@ pub mod sp1;
4245pub mod types;
4346mod zk_utils;
4447
45- const S3_BUCKET_NAME : & str = "storage.alignedlayer.com" ;
46-
4748pub 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
6264impl 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