rpc: in/out peers can now return the setting's value

This commit is contained in:
moneromooo-monero
2019-05-30 12:13:31 +00:00
parent 5fbfa8a656
commit fcfcc3ac86
7 changed files with 63 additions and 21 deletions
+6 -2
View File
@@ -2075,7 +2075,9 @@ namespace cryptonote
bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res, const connection_context *ctx)
{
PERF_TIMER(on_out_peers);
m_p2p.change_max_out_public_peers(req.out_peers);
if (req.set)
m_p2p.change_max_out_public_peers(req.out_peers);
res.out_peers = m_p2p.get_max_out_public_peers();
res.status = CORE_RPC_STATUS_OK;
return true;
}
@@ -2083,7 +2085,9 @@ namespace cryptonote
bool core_rpc_server::on_in_peers(const COMMAND_RPC_IN_PEERS::request& req, COMMAND_RPC_IN_PEERS::response& res, const connection_context *ctx)
{
PERF_TIMER(on_in_peers);
m_p2p.change_max_in_public_peers(req.in_peers);
if (req.set)
m_p2p.change_max_in_public_peers(req.in_peers);
res.in_peers = m_p2p.get_max_in_public_peers();
res.status = CORE_RPC_STATUS_OK;
return true;
}
+11 -3
View File
@@ -84,7 +84,7 @@ namespace cryptonote
// advance which version they will stop working with
// Don't go over 32767 for any of these
#define CORE_RPC_VERSION_MAJOR 2
#define CORE_RPC_VERSION_MINOR 6
#define CORE_RPC_VERSION_MINOR 7
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
@@ -1682,8 +1682,10 @@ namespace cryptonote
{
struct request_t
{
uint64_t out_peers;
bool set;
uint32_t out_peers;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_OPT(set, true)
KV_SERIALIZE(out_peers)
END_KV_SERIALIZE_MAP()
};
@@ -1691,9 +1693,11 @@ namespace cryptonote
struct response_t
{
uint32_t out_peers;
std::string status;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(out_peers)
KV_SERIALIZE(status)
END_KV_SERIALIZE_MAP()
};
@@ -1704,8 +1708,10 @@ namespace cryptonote
{
struct request_t
{
uint64_t in_peers;
bool set;
uint32_t in_peers;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_OPT(set, true)
KV_SERIALIZE(in_peers)
END_KV_SERIALIZE_MAP()
};
@@ -1713,9 +1719,11 @@ namespace cryptonote
struct response_t
{
uint32_t in_peers;
std::string status;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(in_peers)
KV_SERIALIZE(status)
END_KV_SERIALIZE_MAP()
};