Skip to content

Commit

Permalink
Update check
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed May 8, 2024
1 parent 2473f05 commit c06b4ec
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,17 +427,17 @@ impl TransactionBuilder {
work_score += self.protocol_parameters.work_score(&output);
if let Some(allotment) = self.min_mana_allotment {
// If we're allotting to this output account, we will have more mana from the reduction.
if output
.as_account_opt()
.is_some_and(|account| account.account_id() == &allotment.issuer_id)
{
if output.as_account_opt().is_some_and(|account| {
account.is_block_issuer() && account.account_id() == &allotment.issuer_id
}) {
// We can regain as much as the full account mana value
// by reducing the mana on the account.
let new_required_allotment = allotment.required_allotment.unwrap_or_default()
+ (work_score as u64 * allotment.reference_mana_cost);
mana_gained += new_required_allotment.min(output.mana());
}
}
mana_gained = mana_gained.saturating_sub(output.mana());
} else if input.output.native_token().is_some() {
remainder_work_score += self.protocol_parameters.work_score(self.native_token_remainder())
} else if mana_gained > missing_mana {
Expand All @@ -450,7 +450,14 @@ impl TransactionBuilder {
mana_gained = mana_gained.saturating_sub(work_score as u64 * allotment.reference_mana_cost);
}

if mana_gained == 0 {
if mana_gained == 0
&& !(input.output.as_account_opt().is_some_and(|account| {
account.is_block_issuer()
&& self
.min_mana_allotment
.is_some_and(|allotment| *account.account_id() == allotment.issuer_id)
}))
{
return None;
}

Expand Down

0 comments on commit c06b4ec

Please sign in to comment.