mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-04 09:16:47 +00:00
Improve Invariant check handling if not in Transactor context
- Adds an option to isFeatureEnabled to return true if no global rules set. Can be used for functionality that uses the post-amendment behavior when called outside of a Transactor context.
This commit is contained in:
@@ -8,8 +8,13 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/** Check whether a feature is enabled in the current ledger rules
|
||||
*
|
||||
* @param feature The feature to be tested.
|
||||
* @param resultIfNoRules What to return if called from outside a Transactor context.
|
||||
*/
|
||||
bool
|
||||
isFeatureEnabled(uint256 const& feature);
|
||||
isFeatureEnabled(uint256 const& feature, bool resultIfNoRules = false);
|
||||
|
||||
class DigestAwareReadView;
|
||||
|
||||
|
||||
@@ -140,10 +140,12 @@ Rules::operator!=(Rules const& other) const
|
||||
}
|
||||
|
||||
bool
|
||||
isFeatureEnabled(uint256 const& feature)
|
||||
isFeatureEnabled(uint256 const& feature, bool resultIfNoRules)
|
||||
{
|
||||
auto const& rules = getCurrentTransactionRules();
|
||||
return rules && rules->enabled(feature);
|
||||
if (!rules)
|
||||
return resultIfNoRules;
|
||||
return rules->enabled(feature);
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -322,7 +322,7 @@ NoZeroEscrow::visitEntry(
|
||||
bad_ = true;
|
||||
};
|
||||
|
||||
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3);
|
||||
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3, true);
|
||||
|
||||
if (after && after->getType() == ltMPTOKEN_ISSUANCE)
|
||||
{
|
||||
@@ -605,7 +605,7 @@ NoXRPTrustLines::visitEntry(
|
||||
std::shared_ptr<SLE const> const&,
|
||||
std::shared_ptr<SLE const> const& after)
|
||||
{
|
||||
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3);
|
||||
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3, true);
|
||||
|
||||
if (after && after->getType() == ltRIPPLE_STATE)
|
||||
{
|
||||
@@ -646,7 +646,7 @@ NoDeepFreezeTrustLinesWithoutFreeze::visitEntry(
|
||||
{
|
||||
if (after && after->getType() == ltRIPPLE_STATE)
|
||||
{
|
||||
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3);
|
||||
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3, true);
|
||||
|
||||
std::uint32_t const uFlags = after->getFieldU32(sfFlags);
|
||||
bool const lowFreeze = (uFlags & lsfLowFreeze) != 0u;
|
||||
|
||||
Reference in New Issue
Block a user