Use block index when obtaining block's difficulty for log statement

Use last block id, not number of blocks (off-by-one error).

Fixes error at start of blockchain reorganization: "Attempt to get
cumulative difficulty from height <XXXXXX> failed -- difficulty not in
db"
This commit is contained in:
warptangent 2015-01-11 16:59:59 -08:00
parent 030eab7a49
commit 1701c26750
No known key found for this signature in database
GPG key ID: 0E490BEBFBE4E92D

View file

@ -1216,8 +1216,8 @@ bool Blockchain::handle_alternative_block(const block& b, const crypto::hash& id
{ {
//do reorganize! //do reorganize!
LOG_PRINT_GREEN("###### REORGANIZE on height: " LOG_PRINT_GREEN("###### REORGANIZE on height: "
<< alt_chain.front()->second.height << " of " << m_db->height() << alt_chain.front()->second.height << " of " << m_db->height() - 1
<< " with cum_difficulty " << m_db->get_block_cumulative_difficulty(m_db->height()) << " with cum_difficulty " << m_db->get_block_cumulative_difficulty(m_db->height() - 1)
<< std::endl << " alternative blockchain size: " << alt_chain.size() << std::endl << " alternative blockchain size: " << alt_chain.size()
<< " with cum_difficulty " << bei.cumulative_difficulty, LOG_LEVEL_0 << " with cum_difficulty " << bei.cumulative_difficulty, LOG_LEVEL_0
); );