From f65e03216aec8add7fe050eeaded2f383c6f7d05 Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Sun, 5 Oct 2025 14:17:44 +0800 Subject: [PATCH] fix: early return in single ix pipeline --- crates/runtime/src/instruction.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/runtime/src/instruction.rs b/crates/runtime/src/instruction.rs index 3de19f95..cb69fc98 100644 --- a/crates/runtime/src/instruction.rs +++ b/crates/runtime/src/instruction.rs @@ -95,6 +95,7 @@ impl SingleInstructionPipeline { /// # Errors /// Returns an error if the inner pipeline fails. pub async fn handle(&self, txn: &TransactionUpdate) -> Result<(), PipelineErrors> { + let mut err = None; let ixs = InstructionUpdate::parse_from_txn(txn).map_err(PipelineErrors::parse)?; let pipe = &self.0; @@ -107,15 +108,15 @@ impl SingleInstructionPipeline { match res { Ok(()) => (), Err(PipelineErrors::AlreadyHandled(h)) => h.as_unit(), - Err(e) => { - let handled = e.handle::(&pipe.id()); - - return Err(PipelineErrors::AlreadyHandled(handled)); - }, + Err(e) => err = Some(e.handle::(&pipe.id())), } } - Ok(()) + if let Some(h) = err { + Err(PipelineErrors::AlreadyHandled(h)) + } else { + Ok(()) + } } }