mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 03:38:00 +00:00
Synchronize state cache on finalization (#3246)
* Reorg test * Fixed informant misreporting reorgs * Update cache when reorg is caused by applying finality * Test for finality reorg * Simplified test * Typo Co-Authored-By: André Silva <andre.beat@gmail.com>
This commit is contained in:
committed by
André Silva
parent
1295260f2b
commit
1d5cd20c44
@@ -48,15 +48,15 @@ where C: Components {
|
||||
});
|
||||
|
||||
let client = service.client();
|
||||
let mut last = {
|
||||
let mut last_best = {
|
||||
let info = client.info();
|
||||
Some((info.chain.best_number, info.chain.best_hash))
|
||||
};
|
||||
|
||||
let display_block_import = client.import_notification_stream().map(|v| Ok::<_, ()>(v)).compat().for_each(move |n| {
|
||||
// detect and log reorganizations.
|
||||
if let Some((ref last_num, ref last_hash)) = last {
|
||||
if n.header.parent_hash() != last_hash {
|
||||
if let Some((ref last_num, ref last_hash)) = last_best {
|
||||
if n.header.parent_hash() != last_hash && n.is_new_best {
|
||||
let tree_route = ::client::blockchain::tree_route(
|
||||
#[allow(deprecated)]
|
||||
client.backend().blockchain(),
|
||||
@@ -77,7 +77,9 @@ where C: Components {
|
||||
}
|
||||
}
|
||||
|
||||
last = Some((n.header.number().clone(), n.hash.clone()));
|
||||
if n.is_new_best {
|
||||
last_best = Some((n.header.number().clone(), n.hash.clone()));
|
||||
}
|
||||
|
||||
info!(target: "substrate", "Imported #{} ({})", n.header.number(), n.hash);
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user