Optimise isFrozen check for pair of accounts

This commit is contained in:
Bronek Kozicki
2025-02-07 21:25:47 +00:00
parent c1d8bc4928
commit e9ed80026e
3 changed files with 57 additions and 2 deletions

View File

@@ -486,8 +486,7 @@ Payment::doApply()
// - can't send between holders
// - holder can send back to issuer
// - issuer can send to holder
if (isFrozen(view(), account_, mptIssue) ||
isFrozen(view(), dstAccountID, mptIssue))
if (isAnyFrozen(view(), account_, dstAccountID, mptIssue))
return tecLOCKED;
// Get the rate for a payment between the holders.

View File

@@ -154,6 +154,49 @@ isFrozen(ReadView const& view, AccountID const& account, Asset const& asset)
asset.value());
}
[[nodiscard]] bool
isAnyFrozen(
ReadView const& view,
AccountID const& account1,
AccountID const& account2,
MPTIssue const& mptIssue);
/*
We do not have use a case for these (yet ?)
[[nodiscard]] bool
isAnyFrozen(
ReadView const& view,
AccountID const& account1,
AccountID const& account2,
Currency const& currency,
AccountID const& issuer);
[[nodiscard]] inline bool
isAnyFrozen(
ReadView const& view,
AccountID const& account1,
AccountID const& account2,
Issue const& issue)
{
return isAnyFrozen(view, account1, account2, issue.currency, issue.account);
}
[[nodiscard]] inline bool
isAnyFrozen(
ReadView const& view,
AccountID const& account1,
AccountID const& account2,
Asset const& asset)
{
return std::visit(
[&](auto const& issue) {
return isAnyFrozen(view, account1, account2, issue);
},
asset.value());
}
*/
[[nodiscard]] bool
isDeepFrozen(
ReadView const& view,

View File

@@ -280,6 +280,19 @@ isFrozen(
isVaultPseudoAccountFrozen(view, mptIssue);
}
[[nodiscard]] bool
isAnyFrozen(
ReadView const& view,
AccountID const& account1,
AccountID const& account2,
MPTIssue const& mptIssue)
{
return isGlobalFrozen(view, mptIssue) ||
isIndividualFrozen(view, account1, mptIssue) ||
isIndividualFrozen(view, account2, mptIssue) ||
isVaultPseudoAccountFrozen(view, mptIssue);
}
bool
isVaultPseudoAccountFrozen(ReadView const& view, MPTIssue const& mptShare)
{