rpc: fix orphan_status when getting blocks

It was always set to false, even for orphan blocks
This commit is contained in:
moneromooo-monero
2017-01-22 12:20:55 +00:00
parent 71ac698b78
commit b70ab128fc
5 changed files with 16 additions and 9 deletions

View File

@@ -636,7 +636,7 @@ crypto::hash Blockchain::get_block_id_by_height(uint64_t height) const
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__);
CRITICAL_REGION_LOCAL(m_blockchain_lock);
@@ -645,6 +645,8 @@ bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk) const
try
{
blk = m_db->get_block(h);
if (orphan)
*orphan = false;
return true;
}
// 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)
{
blk = it_alt->second.bl;
if (orphan)
*orphan = true;
return true;
}
}