@@ -139,7 +139,6 @@ impl OutboundJITChannelState {
139139 & mut self , opening_fee_params : & LSPS2OpeningFeeParams , payment_size_msat : & Option < u64 > ,
140140 htlc : InterceptedHTLC ,
141141 ) -> Result < Option < HTLCInterceptedAction > , ChannelStateError > {
142- let new_state;
143142 let res = match self {
144143 OutboundJITChannelState :: PendingInitialPayment { payment_queue } => {
145144 let ( total_expected_outbound_amount_msat, num_htlcs) = payment_queue. add_htlc ( htlc) ;
@@ -190,7 +189,7 @@ impl OutboundJITChannelState {
190189 if total_expected_outbound_amount_msat >= expected_payment_size_msat
191190 && amt_to_forward_msat > 0
192191 {
193- new_state = OutboundJITChannelState :: PendingChannelOpen {
192+ * self = OutboundJITChannelState :: PendingChannelOpen {
194193 payment_queue : core:: mem:: take ( payment_queue) ,
195194 opening_fee_msat,
196195 } ;
@@ -201,7 +200,7 @@ impl OutboundJITChannelState {
201200 Ok ( Some ( open_channel) )
202201 } else {
203202 if mpp_mode {
204- new_state = OutboundJITChannelState :: PendingInitialPayment {
203+ * self = OutboundJITChannelState :: PendingInitialPayment {
205204 payment_queue : core:: mem:: take ( payment_queue) ,
206205 } ;
207206 Ok ( None )
@@ -215,7 +214,7 @@ impl OutboundJITChannelState {
215214 OutboundJITChannelState :: PendingChannelOpen { payment_queue, opening_fee_msat } => {
216215 let mut payment_queue = core:: mem:: take ( payment_queue) ;
217216 payment_queue. add_htlc ( htlc) ;
218- new_state = OutboundJITChannelState :: PendingChannelOpen {
217+ * self = OutboundJITChannelState :: PendingChannelOpen {
219218 payment_queue,
220219 opening_fee_msat : * opening_fee_msat,
221220 } ;
@@ -228,7 +227,7 @@ impl OutboundJITChannelState {
228227 } => {
229228 let mut payment_queue = core:: mem:: take ( payment_queue) ;
230229 payment_queue. add_htlc ( htlc) ;
231- new_state = OutboundJITChannelState :: PendingPaymentForward {
230+ * self = OutboundJITChannelState :: PendingPaymentForward {
232231 payment_queue,
233232 opening_fee_msat : * opening_fee_msat,
234233 channel_id : * channel_id,
@@ -245,18 +244,18 @@ impl OutboundJITChannelState {
245244 if let Some ( ( _payment_hash, htlcs) ) =
246245 payment_queue. pop_greater_than_msat ( * opening_fee_msat)
247246 {
248- new_state = OutboundJITChannelState :: PendingPaymentForward {
249- payment_queue,
250- opening_fee_msat : * opening_fee_msat,
251- channel_id : * channel_id,
252- } ;
253247 let forward_payment = HTLCInterceptedAction :: ForwardPayment (
254248 * channel_id,
255249 FeePayment { htlcs, opening_fee_msat : * opening_fee_msat } ,
256250 ) ;
251+ * self = OutboundJITChannelState :: PendingPaymentForward {
252+ payment_queue,
253+ opening_fee_msat : * opening_fee_msat,
254+ channel_id : * channel_id,
255+ } ;
257256 Ok ( Some ( forward_payment) )
258257 } else {
259- new_state = OutboundJITChannelState :: PendingPayment {
258+ * self = OutboundJITChannelState :: PendingPayment {
260259 payment_queue : payment_queue. clone ( ) ,
261260 opening_fee_msat : * opening_fee_msat,
262261 channel_id : * channel_id,
@@ -265,33 +264,31 @@ impl OutboundJITChannelState {
265264 }
266265 } ,
267266 OutboundJITChannelState :: PaymentForwarded { channel_id } => {
268- new_state = OutboundJITChannelState :: PaymentForwarded { channel_id : * channel_id } ;
269267 let forward = HTLCInterceptedAction :: ForwardHTLC ( * channel_id) ;
268+ * self = OutboundJITChannelState :: PaymentForwarded { channel_id : * channel_id } ;
270269 Ok ( Some ( forward) )
271270 } ,
272271 } ;
273- * self = new_state;
274272 res
275273 }
276274
277275 fn channel_ready (
278276 & mut self , channel_id : ChannelId ,
279277 ) -> Result < ForwardPaymentAction , ChannelStateError > {
280- let new_state;
281278 let res = match self {
282279 OutboundJITChannelState :: PendingChannelOpen { payment_queue, opening_fee_msat } => {
283280 if let Some ( ( _payment_hash, htlcs) ) =
284281 payment_queue. pop_greater_than_msat ( * opening_fee_msat)
285282 {
286- new_state = OutboundJITChannelState :: PendingPaymentForward {
287- payment_queue : core:: mem:: take ( payment_queue) ,
288- opening_fee_msat : * opening_fee_msat,
289- channel_id,
290- } ;
291283 let forward_payment = ForwardPaymentAction (
292284 channel_id,
293285 FeePayment { opening_fee_msat : * opening_fee_msat, htlcs } ,
294286 ) ;
287+ * self = OutboundJITChannelState :: PendingPaymentForward {
288+ payment_queue : core:: mem:: take ( payment_queue) ,
289+ opening_fee_msat : * opening_fee_msat,
290+ channel_id,
291+ } ;
295292 Ok ( forward_payment)
296293 } else {
297294 return Err ( ChannelStateError (
@@ -307,12 +304,10 @@ impl OutboundJITChannelState {
307304 ) ) )
308305 } ,
309306 } ;
310- * self = new_state;
311307 res
312308 }
313309
314310 fn htlc_handling_failed ( & mut self ) -> Result < Option < ForwardPaymentAction > , ChannelStateError > {
315- let new_state;
316311 let res = match self {
317312 OutboundJITChannelState :: PendingPaymentForward {
318313 payment_queue,
@@ -322,18 +317,18 @@ impl OutboundJITChannelState {
322317 if let Some ( ( _payment_hash, htlcs) ) =
323318 payment_queue. pop_greater_than_msat ( * opening_fee_msat)
324319 {
325- new_state = OutboundJITChannelState :: PendingPaymentForward {
326- payment_queue : core:: mem:: take ( payment_queue) ,
327- opening_fee_msat : * opening_fee_msat,
328- channel_id : * channel_id,
329- } ;
330320 let forward_payment = ForwardPaymentAction (
331321 * channel_id,
332322 FeePayment { htlcs, opening_fee_msat : * opening_fee_msat } ,
333323 ) ;
324+ * self = OutboundJITChannelState :: PendingPaymentForward {
325+ payment_queue : core:: mem:: take ( payment_queue) ,
326+ opening_fee_msat : * opening_fee_msat,
327+ channel_id : * channel_id,
328+ } ;
334329 Ok ( Some ( forward_payment) )
335330 } else {
336- new_state = OutboundJITChannelState :: PendingPayment {
331+ * self = OutboundJITChannelState :: PendingPayment {
337332 payment_queue : core:: mem:: take ( payment_queue) ,
338333 opening_fee_msat : * opening_fee_msat,
339334 channel_id : * channel_id,
@@ -346,15 +341,15 @@ impl OutboundJITChannelState {
346341 opening_fee_msat,
347342 channel_id,
348343 } => {
349- new_state = OutboundJITChannelState :: PendingPayment {
344+ * self = OutboundJITChannelState :: PendingPayment {
350345 payment_queue : core:: mem:: take ( payment_queue) ,
351346 opening_fee_msat : * opening_fee_msat,
352347 channel_id : * channel_id,
353348 } ;
354349 Ok ( None )
355350 } ,
356351 OutboundJITChannelState :: PaymentForwarded { channel_id } => {
357- new_state = OutboundJITChannelState :: PaymentForwarded { channel_id : * channel_id } ;
352+ * self = OutboundJITChannelState :: PaymentForwarded { channel_id : * channel_id } ;
358353 Ok ( None )
359354 } ,
360355 state => {
@@ -364,23 +359,21 @@ impl OutboundJITChannelState {
364359 ) ) )
365360 } ,
366361 } ;
367- * self = new_state;
368362 res
369363 }
370364
371365 fn payment_forwarded ( & mut self ) -> Result < Option < ForwardHTLCsAction > , ChannelStateError > {
372- let new_state;
373366 let res = match self {
374367 OutboundJITChannelState :: PendingPaymentForward {
375368 payment_queue, channel_id, ..
376369 } => {
377370 let mut payment_queue = core:: mem:: take ( payment_queue) ;
378- new_state = OutboundJITChannelState :: PaymentForwarded { channel_id : * channel_id } ;
379371 let forward_htlcs = ForwardHTLCsAction ( * channel_id, payment_queue. clear ( ) ) ;
372+ * self = OutboundJITChannelState :: PaymentForwarded { channel_id : * channel_id } ;
380373 Ok ( Some ( forward_htlcs) )
381374 } ,
382375 OutboundJITChannelState :: PaymentForwarded { channel_id } => {
383- new_state = OutboundJITChannelState :: PaymentForwarded { channel_id : * channel_id } ;
376+ * self = OutboundJITChannelState :: PaymentForwarded { channel_id : * channel_id } ;
384377 Ok ( None )
385378 } ,
386379 state => {
@@ -390,7 +383,6 @@ impl OutboundJITChannelState {
390383 ) ) )
391384 } ,
392385 } ;
393- * self = new_state;
394386 res
395387 }
396388}
0 commit comments