aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorj-berman <justinberman@protonmail.com>2024-06-24 15:33:07 -0700
committerj-berman <justinberman@protonmail.com>2025-04-10 14:25:54 -0700
commit9a452081495d68861890a107b58c12b8c99d39b4 (patch)
tree0c22e2877c905de84264509a2e2303e8baa9414c
parentc84cc63922da485a2b8617baa7798efeed608758 (diff)
downloadmonzero-core-9a452081495d68861890a107b58c12b8c99d39b4.tar.gz
monzero-core-9a452081495d68861890a107b58c12b8c99d39b4.tar.xz
monzero-core-9a452081495d68861890a107b58c12b8c99d39b4.zip
Daemon RPC: add max_block_count field to /getblocks.bin
-rw-r--r--src/rpc/core_rpc_server.cpp9
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h5
-rw-r--r--src/rpc/daemon_messages.h1
3 files changed, 10 insertions, 5 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index f1ff59e96..b9cd8c7ed 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -710,12 +710,13 @@ namespace cryptonote
}
}
- size_t max_blocks = COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT;
+ size_t max_blocks = req.max_block_count > 0
+ ? std::min(req.max_block_count, (uint64_t)COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT)
+ : COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT;
+
if (m_rpc_payment)
{
- max_blocks = res.credits / COST_PER_BLOCK;
- if (max_blocks > COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT)
- max_blocks = COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT;
+ max_blocks = std::min((size_t)(res.credits / COST_PER_BLOCK), max_blocks);
if (max_blocks == 0)
{
res.status = CORE_RPC_STATUS_PAYMENT_REQUIRED;
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index a9286bd0f..46e52d42f 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)
@@ -177,6 +177,8 @@ namespace cryptonote
bool prune;
bool no_miner_tx;
uint64_t pool_info_since;
+ uint64_t max_block_count;
+
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_PARENT(rpc_access_request_base)
KV_SERIALIZE_OPT(requested_info, (uint8_t)0)
@@ -185,6 +187,7 @@ namespace cryptonote
KV_SERIALIZE(prune)
KV_SERIALIZE_OPT(no_miner_tx, false)
KV_SERIALIZE_OPT(pool_info_since, (uint64_t)0)
+ KV_SERIALIZE_OPT(max_block_count, (uint64_t)0)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;
diff --git a/src/rpc/daemon_messages.h b/src/rpc/daemon_messages.h
index fb33f0d4a..8c9ce1df1 100644
--- a/src/rpc/daemon_messages.h
+++ b/src/rpc/daemon_messages.h
@@ -98,6 +98,7 @@ BEGIN_RPC_MESSAGE_CLASS(GetBlocksFast);
RPC_MESSAGE_MEMBER(uint64_t, start_height);
RPC_MESSAGE_MEMBER(uint64_t, current_height);
RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_output_indices>, output_indices);
+ RPC_MESSAGE_MEMBER(uint64_t, max_block_count);
END_RPC_MESSAGE_RESPONSE;
END_RPC_MESSAGE_CLASS;