Skip to content

Commit 0bb312c

Browse files
committed
Change try_push_to_queue logic
1 parent 3dbf64a commit 0bb312c

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

batcher/aligned-batcher/src/types/batch_queue.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,27 @@ pub(crate) fn try_push_to_queue(
216216
batch_queue: &mut BatchQueue,
217217
item: BatchQueueEntry,
218218
priority: BatchQueueEntryPriority,
219-
_max_batch_byte_size: usize,
220-
_max_batch_proof_qty: usize,
219+
max_batch_byte_size: usize,
220+
max_batch_proof_qty: usize,
221221
) -> Result<(), BatcherError> {
222-
// if let Ok(verification_data_bytes) =
223-
// cbor_serialize(&verification_data.verification_data)
224-
// {
225-
// if queue_len + 1 > self.max_batch_proof_qty ||
226-
// queue_size_bytes + verification_data_bytes.len() + CBOR_ARRAY_MAX_OVERHEAD > self.max_batch_byte_size
227-
// {
228-
// let mut lowest_fee;
229-
230-
// }
231-
// }
232-
233-
batch_queue.push(item, priority);
222+
let queue_len = batch_queue.len();
223+
let queue_size_bytes = calculate_batch_size(&batch_queue)?;
224+
225+
let verification_data_bytes =
226+
cbor_serialize(&item.nonced_verification_data.verification_data)
227+
.map_err(|e|{BatcherError::SerializationError(e.to_string())})?;
228+
229+
if queue_len + 1 > max_batch_proof_qty ||
230+
queue_size_bytes + verification_data_bytes.len() + CBOR_ARRAY_MAX_OVERHEAD > max_batch_byte_size
231+
{
232+
// do something
233+
} else {
234+
batch_queue.push(item, priority);
235+
}
236+
234237
Ok(())
235238
}
239+
236240
#[cfg(test)]
237241
mod test {
238242
use aligned_sdk::core::constants::DEFAULT_CONSTANT_GAS_COST;

0 commit comments

Comments
 (0)