11use aligned_sdk:: communication:: serialization:: { cbor_deserialize, cbor_serialize} ;
2+ use aws_sdk_s3:: operation:: list_bucket_intelligent_tiering_configurations:: builders:: ListBucketIntelligentTieringConfigurationsFluentBuilder ;
23use config:: NonPayingConfig ;
34use connection:: { send_message, WsMessageSink } ;
45use dotenvy:: dotenv;
@@ -16,7 +17,7 @@ use tokio::time::{timeout, Instant};
1617use types:: batch_state:: BatchState ;
1718use types:: user_state:: UserState ;
1819
19- use batch_queue:: calculate_batch_size;
20+ use batch_queue:: { calculate_batch_size, try_push_to_queue } ;
2021use std:: collections:: HashMap ;
2122use std:: env;
2223use std:: net:: SocketAddr ;
@@ -1047,23 +1048,10 @@ impl Batcher {
10471048 let verification_data_comm = verification_data. clone ( ) . into ( ) ;
10481049 info ! ( "Adding verification data to batch..." ) ;
10491050
1050- let mut queue_len = batch_state_lock. batch_queue . len ( ) ;
1051- let mut queue_size_bytes = calculate_batch_size ( & batch_state_lock. batch_queue ) ?;
1052-
1053- if let Ok ( verification_data_bytes) =
1054- cbor_serialize ( & verification_data. verification_data )
1055- {
1056- if queue_len + 1 > self . max_batch_proof_qty ||
1057- queue_size_bytes + verification_data_bytes. len ( ) + CBOR_ARRAY_MAX_OVERHEAD > self . max_batch_byte_size
1058- {
1059- // do something
1060- }
1061- }
1062-
1063-
10641051 let max_fee = verification_data. max_fee ;
10651052 let nonce = verification_data. nonce ;
1066- batch_state_lock. batch_queue . push (
1053+ try_push_to_queue (
1054+ & mut batch_state_lock. batch_queue ,
10671055 BatchQueueEntry :: new (
10681056 verification_data,
10691057 verification_data_comm,
@@ -1072,11 +1060,14 @@ impl Batcher {
10721060 proof_submitter_addr,
10731061 ) ,
10741062 BatchQueueEntryPriority :: new ( max_fee, nonce) ,
1063+ self . max_batch_byte_size ,
1064+ self . max_batch_proof_qty ,
10751065 ) ;
10761066
10771067 // Update metrics
1078- queue_len = batch_state_lock. batch_queue . len ( ) ;
1079- queue_size_bytes = calculate_batch_size ( & batch_state_lock. batch_queue ) ?;
1068+ let queue_len = batch_state_lock. batch_queue . len ( ) ;
1069+ let queue_size_bytes = calculate_batch_size ( & batch_state_lock. batch_queue ) ?;
1070+
10801071 self . metrics
10811072 . update_queue_metrics ( queue_len as i64 , queue_size_bytes as i64 ) ;
10821073
0 commit comments