mirror of
https://github.com/monero-project/monero.git
synced 2024-12-27 19:19:26 -05:00
rpc: fix orphan_status when getting blocks
It was always set to false, even for orphan blocks
This commit is contained in:
parent
71ac698b78
commit
b70ab128fc
@ -636,7 +636,7 @@ crypto::hash Blockchain::get_block_id_by_height(uint64_t height) const
|
|||||||
return null_hash;
|
return null_hash;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk) const
|
bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
@ -645,6 +645,8 @@ bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk) const
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
blk = m_db->get_block(h);
|
blk = m_db->get_block(h);
|
||||||
|
if (orphan)
|
||||||
|
*orphan = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// try to find block in alternative chain
|
// try to find block in alternative chain
|
||||||
@ -654,6 +656,8 @@ bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk) const
|
|||||||
if (m_alternative_chains.end() != it_alt)
|
if (m_alternative_chains.end() != it_alt)
|
||||||
{
|
{
|
||||||
blk = it_alt->second.bl;
|
blk = it_alt->second.bl;
|
||||||
|
if (orphan)
|
||||||
|
*orphan = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,10 +197,11 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @param h the hash to look for
|
* @param h the hash to look for
|
||||||
* @param blk return-by-reference variable to put result block in
|
* @param blk return-by-reference variable to put result block in
|
||||||
|
* @param orphan if non-NULL, will be set to true if not in the main chain, false otherwise
|
||||||
*
|
*
|
||||||
* @return true if the block was found, else false
|
* @return true if the block was found, else false
|
||||||
*/
|
*/
|
||||||
bool get_block_by_hash(const crypto::hash &h, block &blk) const;
|
bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get all block hashes (main chain, alt chains, and invalid blocks)
|
* @brief get all block hashes (main chain, alt chains, and invalid blocks)
|
||||||
|
@ -977,9 +977,9 @@ namespace cryptonote
|
|||||||
return m_blockchain_storage.get_block_id_by_height(height);
|
return m_blockchain_storage.get_block_id_by_height(height);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_block_by_hash(const crypto::hash &h, block &blk) const
|
bool core::get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan) const
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.get_block_by_hash(h, blk);
|
return m_blockchain_storage.get_block_by_hash(h, blk, orphan);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
std::string core::print_pool(bool short_format) const
|
std::string core::print_pool(bool short_format) const
|
||||||
|
@ -330,7 +330,7 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @note see Blockchain::get_block_by_hash
|
* @note see Blockchain::get_block_by_hash
|
||||||
*/
|
*/
|
||||||
bool get_block_by_hash(const crypto::hash &h, block &blk) const;
|
bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::get_alternative_blocks
|
* @copydoc Blockchain::get_alternative_blocks
|
||||||
|
@ -985,7 +985,8 @@ namespace cryptonote
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
block blk;
|
block blk;
|
||||||
bool have_block = m_core.get_block_by_hash(block_hash, blk);
|
bool orphan = false;
|
||||||
|
bool have_block = m_core.get_block_by_hash(block_hash, blk, &orphan);
|
||||||
if (!have_block)
|
if (!have_block)
|
||||||
{
|
{
|
||||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||||
@ -999,7 +1000,7 @@ namespace cryptonote
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
|
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
|
||||||
bool response_filled = fill_block_header_response(blk, false, block_height, block_hash, res.block_header);
|
bool response_filled = fill_block_header_response(blk, orphan, block_height, block_hash, res.block_header);
|
||||||
if (!response_filled)
|
if (!response_filled)
|
||||||
{
|
{
|
||||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||||
@ -1123,7 +1124,8 @@ namespace cryptonote
|
|||||||
block_hash = m_core.get_block_id_by_height(req.height);
|
block_hash = m_core.get_block_id_by_height(req.height);
|
||||||
}
|
}
|
||||||
block blk;
|
block blk;
|
||||||
bool have_block = m_core.get_block_by_hash(block_hash, blk);
|
bool orphan = false;
|
||||||
|
bool have_block = m_core.get_block_by_hash(block_hash, blk, &orphan);
|
||||||
if (!have_block)
|
if (!have_block)
|
||||||
{
|
{
|
||||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||||
@ -1137,7 +1139,7 @@ namespace cryptonote
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
|
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
|
||||||
bool response_filled = fill_block_header_response(blk, false, block_height, block_hash, res.block_header);
|
bool response_filled = fill_block_header_response(blk, orphan, block_height, block_hash, res.block_header);
|
||||||
if (!response_filled)
|
if (!response_filled)
|
||||||
{
|
{
|
||||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||||
|
Loading…
Reference in New Issue
Block a user