mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
- Use powers of two to clearly indicate the bitmask - Replace bitmask with explicit if-conditions to better indicate predicates Change enum values to be powers of two (fix #3417) #4239 Implement the simplified condition evaluation removes the complex bitwise and(&) operator Implement the second proposed solution in Nik Bougalis's comment - Software does not distinguish between different Conditions (Version: 1.5) #3417 (comment) I have tested this code change by performing RPC calls with the commands server_info, server_state, peers and validation_info. These commands worked as expected.
This commit is contained in:
committed by
GitHub
parent
d34e8be316
commit
1c2ae10dc0
@@ -39,8 +39,8 @@ namespace RPC {
|
||||
enum Condition {
|
||||
NO_CONDITION = 0,
|
||||
NEEDS_NETWORK_CONNECTION = 1,
|
||||
NEEDS_CURRENT_LEDGER = 2 + NEEDS_NETWORK_CONNECTION,
|
||||
NEEDS_CLOSED_LEDGER = 4 + NEEDS_NETWORK_CONNECTION,
|
||||
NEEDS_CURRENT_LEDGER = 1 << 1,
|
||||
NEEDS_CLOSED_LEDGER = 1 << 2,
|
||||
};
|
||||
|
||||
struct Handler
|
||||
@@ -94,20 +94,18 @@ conditionMet(Condition condition_required, T& context)
|
||||
}
|
||||
|
||||
if (context.app.getOPs().isAmendmentBlocked() &&
|
||||
(condition_required & NEEDS_CURRENT_LEDGER ||
|
||||
condition_required & NEEDS_CLOSED_LEDGER))
|
||||
(condition_required != NO_CONDITION))
|
||||
{
|
||||
return rpcAMENDMENT_BLOCKED;
|
||||
}
|
||||
|
||||
if (context.app.getOPs().isUNLBlocked() &&
|
||||
(condition_required & NEEDS_CURRENT_LEDGER ||
|
||||
condition_required & NEEDS_CLOSED_LEDGER))
|
||||
(condition_required != NO_CONDITION))
|
||||
{
|
||||
return rpcEXPIRED_VALIDATOR_LIST;
|
||||
}
|
||||
|
||||
if ((condition_required & NEEDS_NETWORK_CONNECTION) &&
|
||||
if ((condition_required != NO_CONDITION) &&
|
||||
(context.netOps.getOperatingMode() < OperatingMode::SYNCING))
|
||||
{
|
||||
JLOG(context.j.info()) << "Insufficient network mode for RPC: "
|
||||
@@ -119,7 +117,7 @@ conditionMet(Condition condition_required, T& context)
|
||||
}
|
||||
|
||||
if (!context.app.config().standalone() &&
|
||||
condition_required & NEEDS_CURRENT_LEDGER)
|
||||
condition_required != NO_CONDITION)
|
||||
{
|
||||
if (context.ledgerMaster.getValidatedLedgerAge() >
|
||||
Tuning::maxValidatedLedgerAge)
|
||||
@@ -143,7 +141,7 @@ conditionMet(Condition condition_required, T& context)
|
||||
}
|
||||
}
|
||||
|
||||
if ((condition_required & NEEDS_CLOSED_LEDGER) &&
|
||||
if ((condition_required != NO_CONDITION) &&
|
||||
!context.ledgerMaster.getClosedLedger())
|
||||
{
|
||||
if (context.apiVersion == 1)
|
||||
|
||||
Reference in New Issue
Block a user