Daemon RPC: high_height_ok req boolean field /getblocks.bin

Behavior before: when start_height > chain tip, response fails

Behavior after: when req.high_height_ok is true && req.start_height
> chain tip, server rerturns a successful response that includes
chain height
This commit is contained in:
j-berman 2024-06-24 16:47:06 -07:00
parent cc73fe7116
commit 356829a198
2 changed files with 13 additions and 3 deletions

View file

@ -702,12 +702,20 @@ namespace cryptonote
if (get_blocks)
{
// quick check for noop
if (!req.block_ids.empty())
if (req.start_height > 0 || !req.block_ids.empty())
{
uint64_t last_block_height;
crypto::hash last_block_hash;
m_core.get_blockchain_top(last_block_height, last_block_hash);
if (last_block_hash == req.block_ids.front())
if (!req.high_height_ok && req.start_height > last_block_height)
{
res.status = "Failed";
return true;
}
if (req.start_height > last_block_height ||
(!req.block_ids.empty() && last_block_hash == req.block_ids.front()))
{
res.start_height = 0;
res.current_height = last_block_height + 1;