Electroneum
Loading...
Searching...
No Matches
jsonrpc_server_handlers_map.h File Reference
Include dependency graph for jsonrpc_server_handlers_map.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BEGIN_JSONRPC2_MAP(t_connection_context)
#define PREPARE_JSONRPC2_OBJECTS_FROM_JSON(command_type)
#define FINALIZE_JSONRPC2_OBJECTS_TO_JSON(method_name)
#define MAP_JSONRPC2_WE(method_name, callback_f, command_type)
#define END_JSONRPC2_MAP()

Macro Definition Documentation

◆ BEGIN_JSONRPC2_MAP

#define BEGIN_JSONRPC2_MAP ( t_connection_context)
Value:
bool handle_rpc_request(const std::string& req_data, \
std::string& resp_data, \
t_connection_context& m_conn_context) \
{ \
bool handled = false; \
if (!ps.load_from_json(req_data)) \
{ \
epee::net_utils::jsonrpc2::make_error_resp_json(-32700, "Parse error", resp_data); \
return true; \
} \
id_ = epee::serialization::storage_entry(std::string()); \
if (!ps.get_value("id", id_, nullptr)) \
{ \
epee::net_utils::jsonrpc2::make_error_resp_json(-32600, "Invalid Request", resp_data); \
return true; \
} \
std::string callback_name; \
if (!ps.get_value("method", callback_name, nullptr)) \
{ \
epee::net_utils::jsonrpc2::make_error_resp_json(-32600, "Invalid Request", resp_data, id_); \
return true; \
} \
if (false) return true;
bool get_value(const std::string &value_name, t_value &val, hsection hparent_section)
bool load_from_json(const std::string &source)
uint64_t get_tick_count()
boost::variant< uint64_t, uint32_t, uint16_t, uint8_t, int64_t, int32_t, int16_t, int8_t, double, bool, std::string, section, array_entry > storage_entry
#define true
unsigned __int64 uint64_t
Definition stdint.h:136

Definition at line 11 of file jsonrpc_server_handlers_map.h.

◆ END_JSONRPC2_MAP

#define END_JSONRPC2_MAP ( )
Value:
epee::net_utils::jsonrpc2::make_error_resp_json(-32601, "Method not found", resp_data, id_); \
return true; \
}
std::string & make_error_resp_json(int64_t code, const std::string &message, std::string &response_data, const epee::serialization::storage_entry &id=nullptr)

Definition at line 81 of file jsonrpc_server_handlers_map.h.

◆ FINALIZE_JSONRPC2_OBJECTS_TO_JSON

#define FINALIZE_JSONRPC2_OBJECTS_TO_JSON ( method_name)
Value:
epee::serialization::store_t_to_json(resp, resp_data, 0, false); \
resp_data += "\n"; \
LOG_PRINT("[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2);

Definition at line 56 of file jsonrpc_server_handlers_map.h.

◆ MAP_JSONRPC2_WE

#define MAP_JSONRPC2_WE ( method_name,
callback_f,
command_type )
Value:
else if (callback_name == method_name) \
{ \
PREPARE_JSONRPC2_OBJECTS_FROM_JSON(command_type) \
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
if(!callback_f(req.params, resp.result, fail_resp.error, m_conn_context)) \
{ \
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), resp_data, 0, false); \
resp_data += "\n"; \
return true; \
} \
FINALIZE_JSONRPC2_OBJECTS_TO_JSON(method_name) \
return true; \
}
#define AUTO_VAL_INIT(v)
response< dummy_result, error > error_response
epee::serialization::storage_entry id

Definition at line 64 of file jsonrpc_server_handlers_map.h.

◆ PREPARE_JSONRPC2_OBJECTS_FROM_JSON

#define PREPARE_JSONRPC2_OBJECTS_FROM_JSON ( command_type)
Value:
handled = true; \
boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
if(!req.load(ps)) \
{ \
epee::net_utils::jsonrpc2::make_error_resp_json(-32602, "Invalid params", resp_data, req.id); \
return true; \
} \
boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
resp.jsonrpc = "2.0"; \
resp.id = req.id;
epee::serialization::storage_entry id

Definition at line 41 of file jsonrpc_server_handlers_map.h.