aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorj-berman <justinberman@protonmail.com>2024-06-24 16:13:18 -0700
committerj-berman <justinberman@protonmail.com>2024-06-24 17:58:20 -0700
commit9f83e7434dd1fb1d8ff8e1ecd8dd6abe4e81dac0 (patch)
treee22c7cf71fb31dbf835b68cdb64bf0f9f1ef3f77 /src/rpc
parentMerge pull request #9202 (diff)
downloadmonero-9f83e7434dd1fb1d8ff8e1ecd8dd6abe4e81dac0.tar.xz
Daemon RPC: /getblocks.bin return chain's top_block_hash in resp
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp3
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h4
-rw-r--r--src/rpc/daemon_handler.cpp2
-rw-r--r--src/rpc/daemon_messages.h1
4 files changed, 7 insertions, 3 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 16d66e79d..92948b6d1 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -711,6 +711,7 @@ namespace cryptonote
{
res.start_height = 0;
res.current_height = last_block_height + 1;
+ res.top_block_hash = last_block_hash;
res.status = CORE_RPC_STATUS_OK;
return true;
}
@@ -730,7 +731,7 @@ namespace cryptonote
}
std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > > bs;
- if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, req.prune, !req.no_miner_tx, max_blocks, COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT))
+ if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.top_block_hash, res.start_height, req.prune, !req.no_miner_tx, max_blocks, COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT))
{
res.status = "Failed";
add_host_fail(ctx);
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index c634b8957..46b17bae9 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -88,7 +88,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 3
-#define CORE_RPC_VERSION_MINOR 14
+#define CORE_RPC_VERSION_MINOR 15
#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)
@@ -232,6 +232,7 @@ namespace cryptonote
std::vector<block_complete_entry> blocks;
uint64_t start_height;
uint64_t current_height;
+ crypto::hash top_block_hash;
std::vector<block_output_indices> output_indices;
uint64_t daemon_time;
uint8_t pool_info_extent;
@@ -244,6 +245,7 @@ namespace cryptonote
KV_SERIALIZE(blocks)
KV_SERIALIZE(start_height)
KV_SERIALIZE(current_height)
+ KV_SERIALIZE_VAL_POD_AS_BLOB_OPT(top_block_hash, crypto::null_hash)
KV_SERIALIZE(output_indices)
KV_SERIALIZE_OPT(daemon_time, (uint64_t) 0)
KV_SERIALIZE_OPT(pool_info_extent, (uint8_t) 0)
diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp
index 4712de134..ef767ffbc 100644
--- a/src/rpc/daemon_handler.cpp
+++ b/src/rpc/daemon_handler.cpp
@@ -128,7 +128,7 @@ namespace rpc
{
std::vector<std::pair<std::pair<blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, blobdata> > > > blocks;
- if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, blocks, res.current_height, res.start_height, req.prune, true, COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT, COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT))
+ if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, blocks, res.current_height, res.top_block_hash, res.start_height, req.prune, true, COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT, COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT))
{
res.status = Message::STATUS_FAILED;
res.error_details = "core::find_blockchain_supplement() returned false";
diff --git a/src/rpc/daemon_messages.h b/src/rpc/daemon_messages.h
index d4b55f8fd..f4e4d00f7 100644
--- a/src/rpc/daemon_messages.h
+++ b/src/rpc/daemon_messages.h
@@ -97,6 +97,7 @@ BEGIN_RPC_MESSAGE_CLASS(GetBlocksFast);
RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_with_transactions>, blocks);
RPC_MESSAGE_MEMBER(uint64_t, start_height);
RPC_MESSAGE_MEMBER(uint64_t, current_height);
+ RPC_MESSAGE_MEMBER(crypto::hash, top_block_hash);
RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_output_indices>, output_indices);
END_RPC_MESSAGE_RESPONSE;
END_RPC_MESSAGE_CLASS;