aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorThomas Winget <tewinget@gmail.com>2014-07-18 19:33:03 -0400
committerThomas Winget <tewinget@gmail.com>2014-07-18 19:33:03 -0400
commit9f88b7ce6bc9845e097a6d67f3d3c97110b819c1 (patch)
tree689d224568a6921f899bb592b7f6ed085f626445 /src/rpc
parentMerge pull request #63 from mikezackles/bytecoin_for_merge (diff)
downloadmonero-9f88b7ce6bc9845e097a6d67f3d3c97110b819c1.tar.xz
Added get_connections RPC call to daemon
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp16
-rw-r--r--src/rpc/core_rpc_server.h2
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h19
3 files changed, 37 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index c3f98563d..1334b5137 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -604,4 +604,20 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool core_rpc_server::on_get_connections(const COMMAND_RPC_GET_CONNECTIONS::request& req, COMMAND_RPC_GET_CONNECTIONS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx)
+ {
+ if(!check_core_busy())
+ {
+ error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
+ error_resp.message = "Core is busy.";
+ return false;
+ }
+
+ res.connections = m_p2p.get_payload_object().get_connections();
+
+ res.status = CORE_RPC_STATUS_OK;
+
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
}
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index abd9e3de7..399a0214f 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -51,6 +51,7 @@ namespace cryptonote
MAP_JON_RPC_WE("getlastblockheader", on_get_last_block_header, COMMAND_RPC_GET_LAST_BLOCK_HEADER)
MAP_JON_RPC_WE("getblockheaderbyhash", on_get_block_header_by_hash, COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH)
MAP_JON_RPC_WE("getblockheaderbyheight", on_get_block_header_by_height, COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT)
+ MAP_JON_RPC_WE("get_connections", on_get_connections, COMMAND_RPC_GET_CONNECTIONS)
END_JSON_RPC_MAP()
END_URI_MAP2()
@@ -74,6 +75,7 @@ namespace cryptonote
bool on_get_last_block_header(const COMMAND_RPC_GET_LAST_BLOCK_HEADER::request& req, COMMAND_RPC_GET_LAST_BLOCK_HEADER::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
bool on_get_block_header_by_hash(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
bool on_get_block_header_by_height(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
+ bool on_get_connections(const COMMAND_RPC_GET_CONNECTIONS::request& req, COMMAND_RPC_GET_CONNECTIONS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
//-----------------------
bool handle_command_line(const boost::program_options::variables_map& vm);
bool check_core_busy();
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 20f73c9d8..39acadb04 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -481,5 +481,24 @@ namespace cryptonote
};
+ struct COMMAND_RPC_GET_CONNECTIONS
+ {
+ struct request
+ {
+ BEGIN_KV_SERIALIZE_MAP()
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ std::string status;
+ std::list<connection_info> connections;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(connections)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ };
}