mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
blockchain: fix random sync failures
When a block is added as part of a chunk (when syncing historical blocks), a block may end up already in the blockchain if it was added to the queue before being added to the chain (though it's not clear how that could happen, but it's an implementation detail) and thus may not be added to the chain when add_block is called. This would cause m_blocks_txs_check to not be cleared, causing it to get out of sync at next call, and thus wrongfully reject the next block.
This commit is contained in:
parent
4f80c50730
commit
6f8779d282
@ -3547,6 +3547,7 @@ bool Blockchain::add_new_block(const block& bl_, block_verification_context& bvc
|
||||
LOG_PRINT_L3("block with id = " << id << " already exists");
|
||||
bvc.m_already_exists = true;
|
||||
m_db->block_txn_stop();
|
||||
m_blocks_txs_check.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3556,7 +3557,9 @@ bool Blockchain::add_new_block(const block& bl_, block_verification_context& bvc
|
||||
//chain switching or wrong block
|
||||
bvc.m_added_to_main_chain = false;
|
||||
m_db->block_txn_stop();
|
||||
return handle_alternative_block(bl, id, bvc);
|
||||
bool r = handle_alternative_block(bl, id, bvc);
|
||||
m_blocks_txs_check.clear();
|
||||
return r;
|
||||
//never relay alternative blocks
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user