From 242a682f46938e65618fb7d9b2d8590a4bd7adf2 Mon Sep 17 00:00:00 2001 From: EthanYuan Date: Fri, 9 Aug 2024 11:45:46 +0800 Subject: [PATCH] fix: when queue is empty, no need build mint tx and clear tx. --- branch-chain-aggregator/src/lib.rs | 1 + branch-chain-aggregator/src/transaction/clear.rs | 7 ++++++- branch-chain-aggregator/src/transaction/leap.rs | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/branch-chain-aggregator/src/lib.rs b/branch-chain-aggregator/src/lib.rs index fc94575f55..17c02a8b28 100644 --- a/branch-chain-aggregator/src/lib.rs +++ b/branch-chain-aggregator/src/lib.rs @@ -262,6 +262,7 @@ impl Aggregator { fn get_rgbpp_queue_requests(&self) -> Result<(Vec, OutPoint), Error> { let (queue_cell, queue_cell_data) = self.get_rgbpp_queue_cell()?; if queue_cell_data.outbox().is_empty() { + info!("No requests in queue"); return Ok((vec![], OutPoint::default())); } let request_ids: Vec = queue_cell_data.outbox().into_iter().collect(); diff --git a/branch-chain-aggregator/src/transaction/clear.rs b/branch-chain-aggregator/src/transaction/clear.rs index 6e07c81735..1f032a5f35 100644 --- a/branch-chain-aggregator/src/transaction/clear.rs +++ b/branch-chain-aggregator/src/transaction/clear.rs @@ -29,9 +29,14 @@ use std::collections::HashMap; impl Aggregator { pub(crate) fn create_clear_queue_tx( &self, - _rgbpp_queue_cells: Vec, + rgbpp_queue_cells: Vec, _queue_cell: OutPoint, ) -> Result { + if rgbpp_queue_cells.is_empty() { + info!("no queue requests to clear"); + return Ok(H256::default()); + } + // get queue cell let (queue_cell, queue_cell_data) = self.get_rgbpp_queue_cell()?; diff --git a/branch-chain-aggregator/src/transaction/leap.rs b/branch-chain-aggregator/src/transaction/leap.rs index 052c36c348..e40d9c35f6 100644 --- a/branch-chain-aggregator/src/transaction/leap.rs +++ b/branch-chain-aggregator/src/transaction/leap.rs @@ -41,6 +41,11 @@ impl Aggregator { requests: Vec, queue_cell: OutPoint, ) -> Result { + if requests.is_empty() { + info!("No requests to mint, skip leap tx"); + return Ok(H256::default()); + } + // Check if the requests of the last leap tx are duplicated, and if so, return immediately. let witness = self.get_last_leap_tx_witness(); if let Ok((witness, tx_hash)) = witness {