@@ -88,6 +88,7 @@ pub struct Batcher {
8888 max_proof_size : usize ,
8989 max_batch_byte_size : usize ,
9090 max_batch_proof_qty : usize ,
91+ max_queue_size : usize ,
9192 last_uploaded_batch_block : Mutex < u64 > ,
9293 pre_verification_is_enabled : bool ,
9394 non_paying_config : Option < NonPayingConfig > ,
@@ -263,6 +264,7 @@ impl Batcher {
263264 max_proof_size : config. batcher . max_proof_size ,
264265 max_batch_byte_size : config. batcher . max_batch_byte_size ,
265266 max_batch_proof_qty : config. batcher . max_batch_proof_qty ,
267+ max_queue_size : config. batcher . max_queue_size ,
266268 last_uploaded_batch_block : Mutex :: new ( last_uploaded_batch_block) ,
267269 pre_verification_is_enabled : config. batcher . pre_verification_is_enabled ,
268270 non_paying_config,
@@ -794,6 +796,23 @@ impl Batcher {
794796 return Ok ( ( ) ) ;
795797 }
796798
799+ // * ---------------------------------------------------------------------*
800+ // * Perform validation over batcher queue *
801+ // * ---------------------------------------------------------------------*
802+
803+ // if max batch qty exceded, remove least priority element
804+ if batch_state_lock. batch_queue . len ( ) == self . max_queue_size {
805+ info ! ( "Queue limit exceded, removing least priority element" ) ;
806+
807+ // if let Some(lowest_priority_entry) = batch_state_lock.batch_queue.pop() {
808+ // send_message(
809+ // lowest_priority_entry.0.messaging_sink.unwrap(),
810+ // SubmitProofResponseMessage::BatchQueueLimitExceededError,
811+ // )
812+ // .await;
813+ // }
814+ }
815+
797816 // * ---------------------------------------------------------------------*
798817 // * Add message data into the queue and update user state *
799818 // * ---------------------------------------------------------------------*
@@ -1028,19 +1047,6 @@ impl Batcher {
10281047 BatchQueueEntryPriority :: new ( max_fee, nonce) ,
10291048 ) ;
10301049
1031- // if max batch qty exceded, remove least priority element
1032- if batch_state_lock. batch_queue . len ( ) > self . max_batch_proof_qty {
1033- info ! ( "Queue limit exceded, removing least priority element" ) ;
1034-
1035- if let Some ( lowest_priority_entry) = batch_state_lock. batch_queue . pop ( ) {
1036- send_message (
1037- lowest_priority_entry. 0 . messaging_sink . unwrap ( ) ,
1038- SubmitProofResponseMessage :: BatchQueueLimitExceededError ,
1039- )
1040- . await ;
1041- }
1042- }
1043-
10441050 // Update metrics
10451051 let queue_len = batch_state_lock. batch_queue . len ( ) ;
10461052 let queue_size_bytes = calculate_batch_size ( & batch_state_lock. batch_queue ) ?;
0 commit comments