From b4495994082d5e90c4368499c415eaa9093bab43 Mon Sep 17 00:00:00 2001 From: tequ Date: Thu, 30 Apr 2026 11:42:42 +0900 Subject: [PATCH] Add `--definitions` CLI flag to output static server definitions without starting server (#708) --- .github/workflows/xahau-ga-nix.yml | 13 +++++++++++++ src/xrpld/app/main/Main.cpp | 11 ++++++++++- src/xrpld/rpc/handlers/Handlers.h | 2 ++ src/xrpld/rpc/handlers/ServerDefinitions.cpp | 9 +++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/xahau-ga-nix.yml b/.github/workflows/xahau-ga-nix.yml index d473630a0..a2636bbb8 100644 --- a/.github/workflows/xahau-ga-nix.yml +++ b/.github/workflows/xahau-ga-nix.yml @@ -464,3 +464,16 @@ jobs: verbose: true plugins: noop use_oidc: true + + - name: Export server definitions + if: matrix.job_type == 'build' && matrix.compiler_id == 'gcc-13-libstdcxx' + run: | + ${{ env.build_dir }}/rippled --definitions | python3 -m json.tool > server_definitions.json + + - name: Upload server definitions + if: matrix.job_type == 'build' && matrix.compiler_id == 'gcc-13-libstdcxx' + uses: actions/upload-artifact@v7 + with: + name: server-definitions + path: server_definitions.json + archive: false diff --git a/src/xrpld/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp index f662e282f..d7b935d75 100644 --- a/src/xrpld/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -387,7 +388,8 @@ run(int argc, char** argv) po::value(), "Specify the range of present ledgers for testing purposes. Min and " "max values are comma separated.")( - "version", "Display the build version."); + "version", "Display the build version.")( + "definitions", "Output server definitions as JSON and exit."); po::options_description data("Ledger/Data Options"); data.add_options()("import", importText.c_str())( @@ -529,6 +531,13 @@ run(int argc, char** argv) return 0; } + if (vm.count("definitions")) + { + auto defs = getStaticServerDefinitions(); + std::cout << Json::FastWriter().write(defs); + return 0; + } + #ifndef ENABLE_TESTS if (vm.count("unittest") || vm.count("unittest-child")) { diff --git a/src/xrpld/rpc/handlers/Handlers.h b/src/xrpld/rpc/handlers/Handlers.h index 549d576b5..0c9dbcb39 100644 --- a/src/xrpld/rpc/handlers/Handlers.h +++ b/src/xrpld/rpc/handlers/Handlers.h @@ -129,6 +129,8 @@ doRipplePathFind(RPC::JsonContext&); Json::Value doServerDefinitions(RPC::JsonContext&); Json::Value +getStaticServerDefinitions(); +Json::Value doServerInfo(RPC::JsonContext&); // for humans Json::Value doServerState(RPC::JsonContext&); // for machines diff --git a/src/xrpld/rpc/handlers/ServerDefinitions.cpp b/src/xrpld/rpc/handlers/ServerDefinitions.cpp index 8441a1f51..628311332 100644 --- a/src/xrpld/rpc/handlers/ServerDefinitions.cpp +++ b/src/xrpld/rpc/handlers/ServerDefinitions.cpp @@ -523,6 +523,15 @@ public: } }; +Json::Value +getStaticServerDefinitions() +{ + static const Definitions defs{}; + Json::Value ret = defs(); + ret[jss::hash] = to_string(defs.getHash()); + return ret; +} + Json::Value doServerDefinitions(RPC::JsonContext& context) {