// SPDX-License-Identifier: Apache-2.0 // Copyright chargebyte GmbH and Contributors to EVerest #include "RpcHandler.hpp" #include #include #include #include #include #include "../helpers/Conversions.hpp" // For to_json() for nlohmann::json #include "../helpers/LimitDecimalPlaces.hpp" namespace rpc { template struct is_optional : std::false_type {}; static const std::chrono::milliseconds REQ_COLLECTION_TIMEOUT( 10); // Timeout for collecting client requests. After this timeout, the requests will be processed. static const std::chrono::milliseconds REQ_PROCESSING_TIMEOUT(50); // Timeout for processing requests. After this timeout, the request will be processed. // Helper functions template struct is_optional> : std::true_type {}; template auto extract_param(const nlohmann::json& j) { if constexpr (is_optional::value) { using InnerT = typename T::value_type; if (j.is_null()) { return std::optional{}; } else { return std::optional{j.get()}; } } else { return j.get(); } } // json-rpc-cpp does not support optional parameters in method signatures // so we need to create our own get_handle function to handle methods with optional parameters correctly template using void_t = void; template class Op, typename... Args> struct detector { using value_t = std::false_type; using type = Default; }; template