Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.h
// Copyright (c) 2010 Satoshi Nakamoto | // Copyright (c) 2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Copyright (c) 2017-2019 The Bitcoin developers | // Copyright (c) 2017-2019 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_RPC_SERVER_H | #ifndef BITCOIN_RPC_SERVER_H | ||||
#define BITCOIN_RPC_SERVER_H | #define BITCOIN_RPC_SERVER_H | ||||
#include "amount.h" | #include "amount.h" | ||||
#include "rpc/command.h" | #include "rpc/commandwithrequestcontext.h" | ||||
#include "rpc/jsonrpcrequest.h" | #include "rpc/jsonrpcrequest.h" | ||||
#include "rpc/protocol.h" | #include "rpc/protocol.h" | ||||
#include "rwcollection.h" | #include "rwcollection.h" | ||||
#include "uint256.h" | #include "uint256.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <functional> | #include <functional> | ||||
Show All 24 Lines | |||||
struct UniValueType { | struct UniValueType { | ||||
explicit UniValueType(UniValue::VType _type) | explicit UniValueType(UniValue::VType _type) | ||||
: typeAny(false), type(_type) {} | : typeAny(false), type(_type) {} | ||||
UniValueType() : typeAny(true) {} | UniValueType() : typeAny(true) {} | ||||
bool typeAny; | bool typeAny; | ||||
UniValue::VType type; | UniValue::VType type; | ||||
}; | }; | ||||
typedef std::map<std::string, std::unique_ptr<RPCCommand>> RPCCommandMap; | typedef std::map<std::string, std::unique_ptr<RPCCommandWithRequestContext>> | ||||
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; | ||||
public: | public: | ||||
RPCServer() {} | RPCServer() {} | ||||
/** | /** | ||||
* Attempts to execute an RPC command from the given request. | * Attempts to execute an RPC command from the given request. | ||||
* If no RPC command exists that matches the request, an error is returned. | * If no RPC command exists that matches the request, an error is returned. | ||||
*/ | */ | ||||
UniValue ExecuteCommand(Config &config, | UniValue ExecuteCommand(Config &config, | ||||
const JSONRPCRequest &request) const; | const JSONRPCRequest &request) const; | ||||
/** | /** | ||||
* Register an RPC command. | * Register an RPC command. | ||||
*/ | */ | ||||
void RegisterCommand(std::unique_ptr<RPCCommand> command); | void RegisterCommand(std::unique_ptr<RPCCommandWithRequestContext> command); | ||||
}; | }; | ||||
/** | /** | ||||
* Query whether RPC is running | * Query whether RPC is running | ||||
*/ | */ | ||||
bool IsRPCRunning(); | bool IsRPCRunning(); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines |