From 0299cb77ca18073daf3cf371f8da013fb596ae48 Mon Sep 17 00:00:00 2001 From: Thomas Winget Date: Tue, 5 Sep 2017 12:20:40 -0400 Subject: Fix various oversights/bugs in ZMQ RPC server code - Add some RPC commands (and touch up a couple others) - some bounds checking - some better pointer management - const correctness and error handling -- Thanks @vtnerd for type help with serialization and CMake changes --- src/rpc/daemon_messages.h | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) (limited to 'src/rpc/daemon_messages.h') diff --git a/src/rpc/daemon_messages.h b/src/rpc/daemon_messages.h index adcd7f7c6..685f66843 100644 --- a/src/rpc/daemon_messages.h +++ b/src/rpc/daemon_messages.h @@ -89,6 +89,7 @@ BEGIN_RPC_MESSAGE_CLASS(GetBlocksFast); BEGIN_RPC_MESSAGE_REQUEST; RPC_MESSAGE_MEMBER(std::list, block_ids); RPC_MESSAGE_MEMBER(uint64_t, start_height); + RPC_MESSAGE_MEMBER(bool, prune); END_RPC_MESSAGE_REQUEST; BEGIN_RPC_MESSAGE_RESPONSE; RPC_MESSAGE_MEMBER(std::vector, blocks); @@ -171,10 +172,11 @@ END_RPC_MESSAGE_CLASS; BEGIN_RPC_MESSAGE_CLASS(StartMining); BEGIN_RPC_MESSAGE_REQUEST; RPC_MESSAGE_MEMBER(std::string, miner_address); - RPC_MESSAGE_MEMBER(uint64_t, thread_count); + RPC_MESSAGE_MEMBER(uint64_t, threads_count); + RPC_MESSAGE_MEMBER(bool, do_background_mining); + RPC_MESSAGE_MEMBER(bool, ignore_battery); END_RPC_MESSAGE_REQUEST; BEGIN_RPC_MESSAGE_RESPONSE; - RPC_MESSAGE_MEMBER(bool, success); END_RPC_MESSAGE_RESPONSE; END_RPC_MESSAGE_CLASS; @@ -182,19 +184,7 @@ BEGIN_RPC_MESSAGE_CLASS(GetInfo); BEGIN_RPC_MESSAGE_REQUEST; END_RPC_MESSAGE_REQUEST; BEGIN_RPC_MESSAGE_RESPONSE; - RPC_MESSAGE_MEMBER(uint64_t, height); - RPC_MESSAGE_MEMBER(uint64_t, target_height); - RPC_MESSAGE_MEMBER(uint64_t, difficulty); - RPC_MESSAGE_MEMBER(uint64_t, target); - RPC_MESSAGE_MEMBER(uint64_t, tx_count); - RPC_MESSAGE_MEMBER(uint64_t, tx_pool_size); - RPC_MESSAGE_MEMBER(uint64_t, alt_blocks_count); - RPC_MESSAGE_MEMBER(uint64_t, outgoing_connections_count); - RPC_MESSAGE_MEMBER(uint64_t, incoming_connections_count); - RPC_MESSAGE_MEMBER(uint64_t, white_peerlist_size); - RPC_MESSAGE_MEMBER(uint64_t, grey_peerlist_size); - RPC_MESSAGE_MEMBER(bool, testnet); - RPC_MESSAGE_MEMBER(crypto::hash, top_block_hash); + RPC_MESSAGE_MEMBER(DaemonInfo, info); END_RPC_MESSAGE_RESPONSE; END_RPC_MESSAGE_CLASS; @@ -202,7 +192,6 @@ BEGIN_RPC_MESSAGE_CLASS(StopMining); BEGIN_RPC_MESSAGE_REQUEST; END_RPC_MESSAGE_REQUEST; BEGIN_RPC_MESSAGE_RESPONSE; - RPC_MESSAGE_MEMBER(bool, success); END_RPC_MESSAGE_RESPONSE; END_RPC_MESSAGE_CLASS; @@ -212,8 +201,9 @@ BEGIN_RPC_MESSAGE_CLASS(MiningStatus); BEGIN_RPC_MESSAGE_RESPONSE; RPC_MESSAGE_MEMBER(bool, active); RPC_MESSAGE_MEMBER(uint64_t, speed); - RPC_MESSAGE_MEMBER(uint64_t, thread_count); + RPC_MESSAGE_MEMBER(uint64_t, threads_count); RPC_MESSAGE_MEMBER(std::string, address); + RPC_MESSAGE_MEMBER(bool, is_background_mining_enabled); END_RPC_MESSAGE_RESPONSE; END_RPC_MESSAGE_CLASS; @@ -273,6 +263,15 @@ BEGIN_RPC_MESSAGE_CLASS(GetBlockHeaderByHeight); END_RPC_MESSAGE_RESPONSE; END_RPC_MESSAGE_CLASS; +BEGIN_RPC_MESSAGE_CLASS(GetBlockHeadersByHeight); + BEGIN_RPC_MESSAGE_REQUEST; + RPC_MESSAGE_MEMBER(std::vector, heights); + END_RPC_MESSAGE_REQUEST; + BEGIN_RPC_MESSAGE_RESPONSE; + RPC_MESSAGE_MEMBER(std::vector, headers); + END_RPC_MESSAGE_RESPONSE; +END_RPC_MESSAGE_CLASS; + BEGIN_RPC_MESSAGE_CLASS(GetBlock); BEGIN_RPC_MESSAGE_REQUEST; END_RPC_MESSAGE_REQUEST; @@ -334,20 +333,6 @@ BEGIN_RPC_MESSAGE_CLASS(StopDaemon); END_RPC_MESSAGE_RESPONSE; END_RPC_MESSAGE_CLASS; -BEGIN_RPC_MESSAGE_CLASS(FastExit); - BEGIN_RPC_MESSAGE_REQUEST; - END_RPC_MESSAGE_REQUEST; - BEGIN_RPC_MESSAGE_RESPONSE; - END_RPC_MESSAGE_RESPONSE; -END_RPC_MESSAGE_CLASS; - -BEGIN_RPC_MESSAGE_CLASS(OutPeers); - BEGIN_RPC_MESSAGE_REQUEST; - END_RPC_MESSAGE_REQUEST; - BEGIN_RPC_MESSAGE_RESPONSE; - END_RPC_MESSAGE_RESPONSE; -END_RPC_MESSAGE_CLASS; - BEGIN_RPC_MESSAGE_CLASS(StartSaveGraph); BEGIN_RPC_MESSAGE_REQUEST; END_RPC_MESSAGE_REQUEST; -- cgit v1.2.3