mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 15:37:56 +00:00
client: Reorg to new best when finalizing divergent branch (#2869)
* client: add tests for reorging on diverged finality * client: mark finalized block as best if diverged from current best chain * client: update meta on set_head * core: add docs about SelectChain to finalize_block * client: improve finality reorg test * client: LongestChain doesn't return client best block * client: LongestChain searches canonical chain
This commit is contained in:
@@ -1118,6 +1118,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
hash.clone(),
|
||||
(number.clone(), hash.clone())
|
||||
)?;
|
||||
meta_updates.push((hash, *number, true, false));
|
||||
} else {
|
||||
return Err(client::error::Error::UnknownBlock(format!("Cannot set head {:?}", set_head)))
|
||||
}
|
||||
|
||||
@@ -497,6 +497,7 @@ impl<Block> LightBlockchainStorage<Block> for LightStorage<Block>
|
||||
let mut transaction = DBTransaction::new();
|
||||
self.set_head_with_transaction(&mut transaction, hash.clone(), (number.clone(), hash.clone()))?;
|
||||
self.db.write(transaction).map_err(db_err)?;
|
||||
self.update_meta(hash, header.number().clone(), true, false);
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ClientError::UnknownBlock(format!("Cannot set head {:?}", id)))
|
||||
|
||||
Reference in New Issue
Block a user