Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.h
| Show First 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | typedef UniValue (*const_rpcfn_type)(const Config &config, | ||||
| const JSONRPCRequest &jsonRequest); | const JSONRPCRequest &jsonRequest); | ||||
| class CRPCCommand { | class CRPCCommand { | ||||
| public: | public: | ||||
| std::string category; | std::string category; | ||||
| std::string name; | std::string name; | ||||
| rpcfn_type actor; | rpcfn_type actor; | ||||
| bool okSafeMode; | bool okSafeMode; | ||||
| bool useConstConfig; | |||||
deadalnix: You should add a `call` method on `CRPCCommand` and do the magic in it and `useConstConfig` and… | |||||
| std::vector<std::string> argNames; | std::vector<std::string> argNames; | ||||
| CRPCCommand(std::string _category, std::string _name, rpcfn_type _actor, | CRPCCommand(std::string _category, std::string _name, rpcfn_type _actor, | ||||
| bool _okSafeMode, std::vector<std::string> _argNames) | bool _okSafeMode, std::vector<std::string> _argNames) | ||||
| : category{std::move(_category)}, name{std::move(_name)}, actor{_actor}, | : category{std::move(_category)}, name{std::move(_name)}, actor{_actor}, | ||||
| okSafeMode{_okSafeMode}, argNames{std::move(_argNames)} {} | okSafeMode{_okSafeMode}, | ||||
| useConstConfig(false), argNames{std::move(_argNames)} {} | |||||
| /** | /** | ||||
| * It is safe to cast from void(const int*) to void(int*) but C++ do not | * It is safe to cast from void(const int*) to void(int*) but C++ do not | ||||
| * understand type variance. As a result, we need to do the dirty job | * understand type variance. As a result, we need to do the dirty job | ||||
| * ourselves. | * ourselves. | ||||
| */ | */ | ||||
deadalnixUnsubmitted Not Done Inline ActionsThis comments needs to be updated to reflect that it's in fact UB, so we need to jump through hoops. deadalnix: This comments needs to be updated to reflect that it's in fact UB, so we need to jump through… | |||||
| CRPCCommand(std::string _category, std::string _name, | CRPCCommand(std::string _category, std::string _name, | ||||
| const_rpcfn_type _actor, bool _okSafeMode, | const_rpcfn_type _actor, bool _okSafeMode, | ||||
| std::vector<std::string> _argNames) | std::vector<std::string> _argNames) | ||||
| : category{std::move(_category)}, name{std::move(_name)}, | : category{std::move(_category)}, name{std::move(_name)}, | ||||
| actor{reinterpret_cast<rpcfn_type>(_actor)}, | actor{reinterpret_cast<rpcfn_type>(_actor)}, okSafeMode{_okSafeMode}, | ||||
| okSafeMode{_okSafeMode}, argNames{std::move(_argNames)} {} | useConstConfig(true), argNames{std::move(_argNames)} {} | ||||
| }; | }; | ||||
| /** | /** | ||||
| * Bitcoin RPC command dispatcher. | * Bitcoin RPC command dispatcher. | ||||
| */ | */ | ||||
| class CRPCTable { | class CRPCTable { | ||||
| private: | private: | ||||
| std::map<std::string, const CRPCCommand *> mapCommands; | std::map<std::string, const CRPCCommand *> mapCommands; | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||
You should add a call method on CRPCCommand and do the magic in it and useConstConfig and actor can become private.
Because we need to cast back and forth, it would actually make sense for actor to be an union.