mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
lock chain.head() for less time (scope it in a block) (#1625)
* lock the chain.head for less tieme (scope it in a block) * actually scope it to that block...
This commit is contained in:
parent
c9c829514b
commit
f15bfbd35b
1 changed files with 9 additions and 3 deletions
|
@ -685,19 +685,24 @@ impl Chain {
|
|||
);
|
||||
|
||||
status.on_save();
|
||||
// replace the chain txhashset with the newly built one
|
||||
// Replace the chain txhashset with the newly built one.
|
||||
{
|
||||
let mut txhashset_ref = self.txhashset.write().unwrap();
|
||||
*txhashset_ref = txhashset;
|
||||
}
|
||||
// setup new head
|
||||
{
|
||||
// Setup new head.
|
||||
let head = {
|
||||
let mut head = self.head.lock().unwrap();
|
||||
*head = Tip::from_block(&header);
|
||||
head.clone()
|
||||
};
|
||||
// Save the new head to the db and rebuild the header by height index.
|
||||
{
|
||||
batch.save_body_head(&head)?;
|
||||
batch.save_header_height(&header)?;
|
||||
batch.build_by_height_index(&header, true)?;
|
||||
}
|
||||
// Commit all the changes to the db.
|
||||
batch.commit()?;
|
||||
|
||||
debug!(
|
||||
|
@ -705,6 +710,7 @@ impl Chain {
|
|||
"chain: txhashset_write: finished committing the batch (head etc.)"
|
||||
);
|
||||
|
||||
// Check for any orphan blocks and process them based on the new chain state.
|
||||
self.check_orphans(header.height + 1);
|
||||
|
||||
status.on_done();
|
||||
|
|
Loading…
Reference in a new issue