mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 20:55:41 +00:00
Optimize tree route to sync faster (#3665)
* Introduce HeaderMetadata and use it for tree_route. Add lowest_common_ancestor. * Add tests.
This commit is contained in:
@@ -19,13 +19,14 @@ futures03 = { package = "futures-preview", version = "0.3.0-alpha.18", features
|
||||
futures-timer = "0.3"
|
||||
linked-hash-map = "0.5"
|
||||
linked_hash_set = "0.1.3"
|
||||
lru-cache = "0.1.1"
|
||||
lru-cache = "0.1.2"
|
||||
rustc-hex = "2.0"
|
||||
rand = "0.6"
|
||||
libp2p = { version = "0.12.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
|
||||
fork-tree = { path = "../../core/utils/fork-tree" }
|
||||
consensus = { package = "substrate-consensus-common", path = "../../core/consensus/common" }
|
||||
client = { package = "substrate-client", path = "../../core/client" }
|
||||
header_metadata = { package = "substrate-header-metadata", path = "../../core/client/header-metadata" }
|
||||
sr-primitives = { path = "../../core/sr-primitives" }
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
|
||||
|
||||
@@ -153,14 +153,8 @@ impl<B, E, Block, RA> Client<Block> for SubstrateClient<B, E, Block, RA> where
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
let tree_route = ::client::blockchain::tree_route(
|
||||
|id| self.header(&id)?.ok_or_else(||
|
||||
client::error::Error::UnknownBlock(format!("{:?}", id))
|
||||
),
|
||||
BlockId::Hash(*block),
|
||||
BlockId::Hash(*base),
|
||||
)?;
|
||||
let ancestor = header_metadata::lowest_common_ancestor(self, *block, *base)?;
|
||||
|
||||
Ok(tree_route.common_block().hash == *base)
|
||||
Ok(ancestor.hash == *base)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user