diff --git a/crates/packet-forward/src/lib.rs b/crates/packet-forward/src/lib.rs index d5441d2..ffbcd7b 100644 --- a/crates/packet-forward/src/lib.rs +++ b/crates/packet-forward/src/lib.rs @@ -177,8 +177,18 @@ pub struct PacketForwardMiddleware { } impl PacketForwardMiddleware { + /// Return an immutable ref to the next middleware. + pub fn next(&self) -> &M { + &self.next + } + + /// Return a mutable ref to the next middleware. + pub fn next_mut(&mut self) -> &mut M { + &mut self.next + } + /// Wrap an existing middleware in the PFM. - pub const fn next(next: M) -> Self { + pub const fn wrap(next: M) -> Self { Self { next } } } diff --git a/crates/packet-forward/src/tests/utils.rs b/crates/packet-forward/src/tests/utils.rs index 3b36195..9734438 100644 --- a/crates/packet-forward/src/tests/utils.rs +++ b/crates/packet-forward/src/tests/utils.rs @@ -456,7 +456,7 @@ fn failure_injection_err_msg(point: FailurePoint) -> String { pub type DummyPfm = PacketForwardMiddleware>; pub fn get_dummy_pfm() -> DummyPfm { - PacketForwardMiddleware::next(Store::new(DummyTransferModule::new())) + PacketForwardMiddleware::wrap(Store::new(DummyTransferModule::new())) } pub fn get_dummy_coin(amount: u64) -> Coin {