From c2250d30cc25898ca2f813c2b67d21477cb4b654 Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Fri, 30 Jun 2023 11:33:02 -0700 Subject: [PATCH] Revert "fix: Update Handler::Condition enum values #3417 (#4239)" This reverts commit 1c2ae10dc057d5c7c76d0df2c5a92fc753e4769a. --- src/ripple/rpc/impl/Handler.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ripple/rpc/impl/Handler.h b/src/ripple/rpc/impl/Handler.h index e2188ef51e7..73f2232d5cd 100644 --- a/src/ripple/rpc/impl/Handler.h +++ b/src/ripple/rpc/impl/Handler.h @@ -39,8 +39,8 @@ namespace RPC { enum Condition { NO_CONDITION = 0, NEEDS_NETWORK_CONNECTION = 1, - NEEDS_CURRENT_LEDGER = 1 << 1, - NEEDS_CLOSED_LEDGER = 1 << 2, + NEEDS_CURRENT_LEDGER = 2 + NEEDS_NETWORK_CONNECTION, + NEEDS_CLOSED_LEDGER = 4 + NEEDS_NETWORK_CONNECTION, }; struct Handler @@ -94,18 +94,20 @@ conditionMet(Condition condition_required, T& context) } if (context.app.getOPs().isAmendmentBlocked() && - (condition_required != NO_CONDITION)) + (condition_required & NEEDS_CURRENT_LEDGER || + condition_required & NEEDS_CLOSED_LEDGER)) { return rpcAMENDMENT_BLOCKED; } if (context.app.getOPs().isUNLBlocked() && - (condition_required != NO_CONDITION)) + (condition_required & NEEDS_CURRENT_LEDGER || + condition_required & NEEDS_CLOSED_LEDGER)) { return rpcEXPIRED_VALIDATOR_LIST; } - if ((condition_required != NO_CONDITION) && + if ((condition_required & NEEDS_NETWORK_CONNECTION) && (context.netOps.getOperatingMode() < OperatingMode::SYNCING)) { JLOG(context.j.info()) << "Insufficient network mode for RPC: " @@ -117,7 +119,7 @@ conditionMet(Condition condition_required, T& context) } if (!context.app.config().standalone() && - condition_required != NO_CONDITION) + condition_required & NEEDS_CURRENT_LEDGER) { if (context.ledgerMaster.getValidatedLedgerAge() > Tuning::maxValidatedLedgerAge) @@ -141,7 +143,7 @@ conditionMet(Condition condition_required, T& context) } } - if ((condition_required != NO_CONDITION) && + if ((condition_required & NEEDS_CLOSED_LEDGER) && !context.ledgerMaster.getClosedLedger()) { if (context.apiVersion == 1)