Merge pull request #9381

df54d8b Daemon RPC: add max_block_count field to /getblocks.bin (j-berman)
This commit is contained in:
luigi1111 2024-12-23 10:28:57 -05:00
commit 414fe26254
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010
3 changed files with 9 additions and 4 deletions

View File

@ -725,12 +725,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) if (m_rpc_payment)
{ {
max_blocks = res.credits / COST_PER_BLOCK; max_blocks = std::min((size_t)(res.credits / COST_PER_BLOCK), max_blocks);
if (max_blocks > COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT)
max_blocks = COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT;
if (max_blocks == 0) if (max_blocks == 0)
{ {
res.status = CORE_RPC_STATUS_PAYMENT_REQUIRED; res.status = CORE_RPC_STATUS_PAYMENT_REQUIRED;

View File

@ -191,6 +191,8 @@ inline const std::string get_rpc_status(const bool trusted_daemon, const std::st
bool no_miner_tx; bool no_miner_tx;
bool high_height_ok; bool high_height_ok;
uint64_t pool_info_since; uint64_t pool_info_since;
uint64_t max_block_count;
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE_PARENT(rpc_access_request_base) KV_SERIALIZE_PARENT(rpc_access_request_base)
KV_SERIALIZE_OPT(requested_info, (uint8_t)0) KV_SERIALIZE_OPT(requested_info, (uint8_t)0)
@ -200,6 +202,7 @@ inline const std::string get_rpc_status(const bool trusted_daemon, const std::st
KV_SERIALIZE_OPT(no_miner_tx, false) KV_SERIALIZE_OPT(no_miner_tx, false)
KV_SERIALIZE_OPT(high_height_ok, false) // default false maintains backwards compatibility for clients that relied on failure on high height KV_SERIALIZE_OPT(high_height_ok, false) // default false maintains backwards compatibility for clients that relied on failure on high height
KV_SERIALIZE_OPT(pool_info_since, (uint64_t)0) KV_SERIALIZE_OPT(pool_info_since, (uint64_t)0)
KV_SERIALIZE_OPT(max_block_count, (uint64_t)0)
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };
typedef epee::misc_utils::struct_init<request_t> request; typedef epee::misc_utils::struct_init<request_t> request;

View File

@ -99,6 +99,7 @@ BEGIN_RPC_MESSAGE_CLASS(GetBlocksFast);
RPC_MESSAGE_MEMBER(uint64_t, current_height); RPC_MESSAGE_MEMBER(uint64_t, current_height);
RPC_MESSAGE_MEMBER(crypto::hash, top_block_hash); RPC_MESSAGE_MEMBER(crypto::hash, top_block_hash);
RPC_MESSAGE_MEMBER(std::vector<cryptonote::rpc::block_output_indices>, output_indices); 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_RESPONSE;
END_RPC_MESSAGE_CLASS; END_RPC_MESSAGE_CLASS;