Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.h
Show All 29 Lines | |||||
namespace RPCServerSignals { | namespace RPCServerSignals { | ||||
void OnStarted(std::function<void()> slot); | void OnStarted(std::function<void()> slot); | ||||
void OnStopped(std::function<void()> slot); | void OnStopped(std::function<void()> slot); | ||||
} // namespace RPCServerSignals | } // namespace RPCServerSignals | ||||
class Config; | class Config; | ||||
/** | |||||
* Wrapper for UniValue::VType, which includes typeAny: used to denote don't | |||||
* care type. | |||||
*/ | |||||
struct UniValueType { | |||||
UniValueType(UniValue::VType _type) : typeAny(false), type(_type) {} | |||||
UniValueType() : typeAny(true) {} | |||||
bool typeAny; | |||||
UniValue::VType type; | |||||
}; | |||||
typedef std::map<std::string, std::unique_ptr<RPCCommand>> RPCCommandMap; | typedef std::map<std::string, std::unique_ptr<RPCCommand>> RPCCommandMap; | ||||
/** | /** | ||||
* Class for registering and managing all RPC calls. | * Class for registering and managing all RPC calls. | ||||
*/ | */ | ||||
class RPCServer : public boost::noncopyable { | class RPCServer : public boost::noncopyable { | ||||
private: | private: | ||||
RWCollection<RPCCommandMap> commands; | RWCollection<RPCCommandMap> commands; | ||||
Show All 31 Lines | |||||
void SetRPCWarmupFinished(); | void SetRPCWarmupFinished(); | ||||
/** | /** | ||||
* Returns the current warmup state | * Returns the current warmup state | ||||
*/ | */ | ||||
bool RPCIsInWarmup(std::string *outStatus); | bool RPCIsInWarmup(std::string *outStatus); | ||||
/** | /** | ||||
* Type-check arguments; throws JSONRPCError if wrong type given. Does not check | |||||
* that the right number of arguments are passed, just that any passed are the | |||||
* correct type. | |||||
*/ | |||||
void RPCTypeCheck(const UniValue ¶ms, | |||||
const std::list<UniValueType> &typesExpected, | |||||
bool fAllowNull = false); | |||||
/** | |||||
* Type-check one argument; throws JSONRPCError if wrong type given. | |||||
*/ | |||||
void RPCTypeCheckArgument(const UniValue &value, | |||||
const UniValueType &typeExpected); | |||||
/** | |||||
* Check for expected keys/value types in an Object. | |||||
*/ | |||||
void RPCTypeCheckObj(const UniValue &o, | |||||
const std::map<std::string, UniValueType> &typesExpected, | |||||
bool fAllowNull = false, bool fStrict = false); | |||||
/** | |||||
* Opaque base class for timers returned by NewTimerFunc. | * Opaque base class for timers returned by NewTimerFunc. | ||||
* This provides no methods at the moment, but makes sure that delete cleans up | * This provides no methods at the moment, but makes sure that delete cleans up | ||||
* the whole state. | * the whole state. | ||||
*/ | */ | ||||
class RPCTimerBase { | class RPCTimerBase { | ||||
public: | public: | ||||
virtual ~RPCTimerBase() {} | virtual ~RPCTimerBase() {} | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | public: | ||||
bool appendCommand(const std::string &name, const CRPCCommand *pcmd); | bool appendCommand(const std::string &name, const CRPCCommand *pcmd); | ||||
bool removeCommand(const std::string &name, const CRPCCommand *pcmd); | bool removeCommand(const std::string &name, const CRPCCommand *pcmd); | ||||
}; | }; | ||||
bool IsDeprecatedRPCEnabled(ArgsManager &args, const std::string &method); | bool IsDeprecatedRPCEnabled(ArgsManager &args, const std::string &method); | ||||
extern CRPCTable tableRPC; | extern CRPCTable tableRPC; | ||||
/** | |||||
* Utilities: convert hex-encoded values (throws error if not hex). | |||||
*/ | |||||
extern uint256 ParseHashV(const UniValue &v, std::string strName); | |||||
extern uint256 ParseHashO(const UniValue &o, std::string strKey); | |||||
extern std::vector<uint8_t> ParseHexV(const UniValue &v, std::string strName); | |||||
extern std::vector<uint8_t> ParseHexO(const UniValue &o, std::string strKey); | |||||
extern Amount AmountFromValue(const UniValue &value); | |||||
extern std::string HelpExampleCli(const std::string &methodname, | |||||
const std::string &args); | |||||
extern std::string HelpExampleRpc(const std::string &methodname, | |||||
const std::string &args); | |||||
void StartRPC(); | void StartRPC(); | ||||
void InterruptRPC(); | void InterruptRPC(); | ||||
void StopRPC(); | void StopRPC(); | ||||
std::string JSONRPCExecBatch(Config &config, RPCServer &rpcServer, | std::string JSONRPCExecBatch(Config &config, RPCServer &rpcServer, | ||||
const JSONRPCRequest &req, const UniValue &vReq); | const JSONRPCRequest &req, const UniValue &vReq); | ||||
/** | /** | ||||
* Retrieves any serialization flags requested in command line argument | * Retrieves any serialization flags requested in command line argument | ||||
*/ | */ | ||||
int RPCSerializationFlags(); | int RPCSerializationFlags(); | ||||
#endif // BITCOIN_RPC_SERVER_H | #endif // BITCOIN_RPC_SERVER_H |