aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortobtoht <tob@featherwallet.org>2025-09-28 18:37:02 +0000
committertobtoht <tob@featherwallet.org>2025-09-28 18:37:02 +0000
commita440e917906b92b74daa107e49fcb963266242fa (patch)
tree374771f916265495afb88ae3446c6e2becf9be58 /src
parent6ee94b07df334c3d1733c7ed91da3fa0b804914c (diff)
parent9a452081495d68861890a107b58c12b8c99d39b4 (diff)
downloadmonzero-core-a440e917906b92b74daa107e49fcb963266242fa.tar.gz
monzero-core-a440e917906b92b74daa107e49fcb963266242fa.tar.xz
monzero-core-a440e917906b92b74daa107e49fcb963266242fa.zip
Merge pull request #9901
9a45208 Daemon RPC: add max_block_count field to /getblocks.bin (j-berman)
Diffstat (limited to 'src')
-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 5d8a700e2..d0c91876f 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 d671840d7..5ec25ec10 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;