mirror of
https://github.com/XRPLF/rippled.git
synced 2026-10-19 18:18:12 +00:00
Nine conditions reject a request before it reaches a handler, and seven of them write their reply twice over: once as a plain-text body with an HTTP status for a lone request, and once as an error object appended to the reply array for a batch entry. The same fix has to be made seven times, and another condition means another copy. Collapse them into one `reject` helper that answers either shape and reports whether the loop has more to do, so a caller reads `if (!reject(...)) return; continue;`. Each shape is preserved exactly, including the asymmetry. Two of the nine return the entry under `request`: the one naming an `api_version` the server cannot serve, which asks for that shape through `wrapRequest`, and an entry that is not an object, which stays inline, having no members to carry an error. Six carry the error beside the entry's own members, and `params unparsable` reaches a lone request only, that form's entries being flat. No reply changes. The codes these paths report are declared in protocol/JsonRpc.h beside the protocol version, so the four file-local copies go. The header declares every JSON-RPC error code this server reports as one set, so three of them, `kJsonRpcInvalidRequest`, `kJsonRpcInvalidParams` and `kJsonRpcServerError`, have no user until a later branch reports them. The consumer now comes from `requestInboundEndpoint`, which the WebSocket upgrade path already uses, leaving the overload check as a condition beside the others rather than nested inside endpoint construction. Two tests pin the shape a rejected batch entry keeps: a null `method` reports `-32601` with `Null method`, and an entry that is not an object is echoed under `request`. The suite gains `overloadEndpoint`, which charges an address past the drop threshold, for the privileged-request case.