blockchain: fix setting non trovial alternate chain as invalid
The wrong iterator was being used. Also preincrement iterators to avoid possibly invalidating them, I'm not sure this is necessary, but let's be safe.
This commit is contained in:
parent
45bb393577
commit
dfbb85b6fe
@ -832,12 +832,12 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<blocks_ext_by_hash::
|
|||||||
// looking into.
|
// looking into.
|
||||||
add_block_as_invalid(ch_ent->second, get_block_hash(ch_ent->second.bl));
|
add_block_as_invalid(ch_ent->second, get_block_hash(ch_ent->second.bl));
|
||||||
LOG_PRINT_L1("The block was inserted as invalid while connecting new alternative chain, block_id: " << get_block_hash(ch_ent->second.bl));
|
LOG_PRINT_L1("The block was inserted as invalid while connecting new alternative chain, block_id: " << get_block_hash(ch_ent->second.bl));
|
||||||
m_alternative_chains.erase(ch_ent);
|
m_alternative_chains.erase(*alt_ch_iter++);
|
||||||
|
|
||||||
for(auto alt_ch_to_orph_iter = ++alt_ch_iter; alt_ch_to_orph_iter != alt_chain.end(); alt_ch_to_orph_iter++)
|
for(auto alt_ch_to_orph_iter = alt_ch_iter; alt_ch_to_orph_iter != alt_chain.end(); )
|
||||||
{
|
{
|
||||||
add_block_as_invalid((*alt_ch_iter)->second, (*alt_ch_iter)->first);
|
add_block_as_invalid((*alt_ch_to_orph_iter)->second, (*alt_ch_to_orph_iter)->first);
|
||||||
m_alternative_chains.erase(*alt_ch_to_orph_iter);
|
m_alternative_chains.erase(*alt_ch_to_orph_iter++);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user