Skip to content
Snippets Groups Projects
Unverified Commit 0805651d authored by Max Inden's avatar Max Inden
Browse files

core/network/sync: Ask for block from all peers if none provided

When requesting an explicit fork sync, try to sync from all known peers,
when no specific peers were provided.
parent 8e7663c3
Branches
No related merge requests found
......@@ -456,14 +456,20 @@ impl<B: BlockT> ChainSync<B> {
/// Request syncing for the given block from given set of peers.
// The implementation is similar to on_block_announce with unknown parent hash.
pub fn set_sync_fork_request(&mut self, peers: Vec<PeerId>, hash: &B::Hash, number: NumberFor<B>) {
pub fn set_sync_fork_request(&mut self, mut peers: Vec<PeerId>, hash: &B::Hash, number: NumberFor<B>) {
if peers.is_empty() {
if let Some(_) = self.fork_targets.remove(hash) {
debug!(target: "sync", "Cleared sync request for block {:?} with {:?}", hash, peers);
}
return;
debug!(
target: "sync",
"Explicit sync request for block {:?} with no peers specified. \
Syncing from all connected peers {:?} instead.",
hash, peers,
);
peers = self.peers.iter().map(|(id, _)| id.clone()).collect();
} else {
debug!(target: "sync", "Explicit sync request for block {:?} with {:?}", hash, peers);
}
debug!(target: "sync", "Explicit sync request for block {:?} with {:?}", hash, peers);
if self.is_known(&hash) {
debug!(target: "sync", "Refusing to sync known hash {:?}", hash);
return;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment