Skip to content

Commit

Permalink
update transaction-payment (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjb0807 authored May 20, 2021
1 parent 5dc0674 commit a12ac98
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,11 @@ where
let tip = self.0;
let fee = Pallet::<T>::compute_fee(len as u32, info, tip);

// Only mess with balances if fee is not zero.
if fee.is_zero() {
return Ok((fee, None));
}

let reason = if tip.is_zero() {
WithdrawReasons::TRANSACTION_PAYMENT
} else {
Expand Down Expand Up @@ -758,12 +763,10 @@ where
// is gone in that case.
Err(_) => payed,
};
let imbalances = actual_payment.split(tip);
let (tip, fee) = actual_payment.split(tip);

// distribute fee
<T as Config>::OnTransactionPayment::on_unbalanceds(
Some(imbalances.0).into_iter().chain(Some(imbalances.1)),
);
<T as Config>::OnTransactionPayment::on_unbalanceds(Some(fee).into_iter().chain(Some(tip)));
}
Ok(())
}
Expand Down

0 comments on commit a12ac98

Please sign in to comment.