mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-28 15:58:07 +00:00
A new MethodNames.h gives every RPC method a string_view constant, shared by the handler table and the command-line parser table so the two cannot drift apart. That lets a handler carry its name as a string_view, and both tables become sorted constexpr arrays found by binary search, replacing the HandlerTable singleton and its multimap and RPCParser's runtime table. Their invariants -- a unique name, a method, and a valid API version range -- are now a static_assert rather than a logicError on the first request of the process. Handler::Method becomes a plain function pointer: every method is a free function known at compile time, so the std::function never captured anything, and dropping it makes Handler a literal type, which is what a constexpr table needs; it also makes doCommand's null-method branch dead, since an empty std::function is no longer representable. The names being program-lifetime constants removes work throughout. getHandlerNames and commandLineMethodNames return a span over a constexpr array instead of building a fresh std::set per call, one of those on the startup path; PerfLogImp's rpc map keys on string_view, so it needs neither a transparent hasher nor a string copy per key, and reports counters through json::StaticString rather than duplicating each key into the object. Command parameter counts become unsigned with a named kUnlimitedParams; as ints with -1 for unlimited they were compared against an unsigned size, so `count < minParams` promoted -1 and was always true, and only the `>= 0` guards kept that from being reachable. PerfLog no longer reaches into the RPC layer to learn which methods to count: makePerfLog takes the names, so xrpld.perflog stops depending on xrpld.rpc, and PerfLog_test uses five made-up labels, which drops test.basics > xrpld.rpc as well. Both edges are gone from levelization. Handler_test's benchmark now asks for kApiMinimumSupportedVersion instead of a hardcoded 1 and fails if a lookup misses -- once API versions 1 and 2 retire, getHandler(1, ...) would return at its bounds check and the benchmark would have silently reported timings for that check. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>