From 51a75493ae2e381f5f0aa29d3ce91f8e748c6378 Mon Sep 17 00:00:00 2001 From: JCW Date: Thu, 8 Jan 2026 12:16:01 +0000 Subject: [PATCH] Move LedgerShortcut to libxrpl.protocol as it's a protocol thing Signed-off-by: JCW --- include/xrpl/protocol/LedgerShortcut.h | 25 +++++++++++++++++++++++++ src/xrpld/app/rdb/RelationalDatabase.h | 4 +--- src/xrpld/rpc/detail/RPCLedgerHelpers.h | 3 +-- src/xrpld/rpc/handlers/AccountTx.cpp | 2 -- 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 include/xrpl/protocol/LedgerShortcut.h diff --git a/include/xrpl/protocol/LedgerShortcut.h b/include/xrpl/protocol/LedgerShortcut.h new file mode 100644 index 0000000000..0795f391cb --- /dev/null +++ b/include/xrpl/protocol/LedgerShortcut.h @@ -0,0 +1,25 @@ +#ifndef XRPL_PROTOCOL_LEDGERSHORTCUT_H_INCLUDED +#define XRPL_PROTOCOL_LEDGERSHORTCUT_H_INCLUDED + +namespace xrpl { + +/** + * @brief Enumeration of ledger shortcuts for specifying which ledger to use. + * + * These shortcuts provide a convenient way to reference commonly used ledgers + * without needing to specify their exact hash or sequence number. + */ +enum class LedgerShortcut { + /** The current working ledger (open, not yet closed) */ + Current, + + /** The most recently closed ledger (may not be validated) */ + Closed, + + /** The most recently validated ledger */ + Validated +}; + +} // namespace xrpl + +#endif diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h index 4a38b493cd..e9df1c7de4 100644 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ b/src/xrpld/app/rdb/RelationalDatabase.h @@ -1,13 +1,12 @@ #ifndef XRPL_APP_RDB_RELATIONALDATABASE_H_INCLUDED #define XRPL_APP_RDB_RELATIONALDATABASE_H_INCLUDED -#include #include #include -#include #include #include +#include #include #include @@ -71,7 +70,6 @@ public: using LedgerSequence = uint32_t; using LedgerHash = uint256; - using LedgerShortcut = RPC::LedgerShortcut; using LedgerSpecifier = std::variant; diff --git a/src/xrpld/rpc/detail/RPCLedgerHelpers.h b/src/xrpld/rpc/detail/RPCLedgerHelpers.h index 8fe81ef024..1a29312cf5 100644 --- a/src/xrpld/rpc/detail/RPCLedgerHelpers.h +++ b/src/xrpld/rpc/detail/RPCLedgerHelpers.h @@ -8,6 +8,7 @@ #include #include +#include #include @@ -20,8 +21,6 @@ namespace RPC { struct JsonContext; -enum class LedgerShortcut { Current, Closed, Validated }; - /** * @brief Retrieves a ledger by its hash. * diff --git a/src/xrpld/rpc/handlers/AccountTx.cpp b/src/xrpld/rpc/handlers/AccountTx.cpp index 77d388c190..87c054f5b1 100644 --- a/src/xrpld/rpc/handlers/AccountTx.cpp +++ b/src/xrpld/rpc/handlers/AccountTx.cpp @@ -26,8 +26,6 @@ using TxnsDataBinary = RelationalDatabase::MetaTxsList; using TxnDataBinary = RelationalDatabase::txnMetaLedgerType; using AccountTxArgs = RelationalDatabase::AccountTxArgs; using AccountTxResult = RelationalDatabase::AccountTxResult; - -using LedgerShortcut = RelationalDatabase::LedgerShortcut; using LedgerSpecifier = RelationalDatabase::LedgerSpecifier; // parses args into a ledger specifier, or returns a Json object on error