@@ -330,11 +330,16 @@ pub mod pallet {
330
330
} ) ;
331
331
332
332
// compute actual dispatch weight that depends on the stored message size
333
- let actual_weight = sp_std:: cmp:: min_by (
334
- T :: WeightInfo :: maximal_increase_message_fee ( ) ,
335
- T :: WeightInfo :: increase_message_fee ( message_size as _ ) ,
336
- |w1, w2| w1. ref_time ( ) . cmp ( & w2. ref_time ( ) ) ,
337
- ) ;
333
+ let maximal_increase_message_fee = T :: WeightInfo :: maximal_increase_message_fee ( ) ;
334
+ let current_increase_message_fee =
335
+ T :: WeightInfo :: increase_message_fee ( message_size as _ ) ;
336
+ let actual_weight = if maximal_increase_message_fee. ref_time ( ) <
337
+ current_increase_message_fee. ref_time ( )
338
+ {
339
+ maximal_increase_message_fee
340
+ } else {
341
+ current_increase_message_fee
342
+ } ;
338
343
339
344
Ok ( PostDispatchInfo { actual_weight : Some ( actual_weight) , pays_fee : Pays :: Yes } )
340
345
}
@@ -454,10 +459,11 @@ pub mod pallet {
454
459
ReceivalResult :: TooManyUnconfirmedMessages => ( dispatch_weight, true ) ,
455
460
} ;
456
461
457
- let unspent_weight =
458
- sp_std:: cmp:: min_by ( unspent_weight, dispatch_weight, |w1, w2| {
459
- w1. ref_time ( ) . cmp ( & w2. ref_time ( ) )
460
- } ) ;
462
+ let unspent_weight = if unspent_weight. ref_time ( ) < dispatch_weight. ref_time ( ) {
463
+ unspent_weight
464
+ } else {
465
+ dispatch_weight
466
+ } ;
461
467
dispatch_weight_left -= dispatch_weight - unspent_weight;
462
468
actual_weight = actual_weight. saturating_sub ( unspent_weight) . saturating_sub (
463
469
// delivery call weight formula assumes that the fee is paid at
0 commit comments