diff --git a/sync/src/block/downloader/header.rs b/sync/src/block/downloader/header.rs index 1422c1acf9..68857da46e 100644 --- a/sync/src/block/downloader/header.rs +++ b/sync/src/block/downloader/header.rs @@ -62,6 +62,10 @@ impl HeaderDownloader { } } + pub fn update_pivot(&mut self, hash: BlockHash) { + self.pivot = hash; + } + pub fn best_hash(&self) -> BlockHash { self.best_hash } diff --git a/sync/src/block/extension.rs b/sync/src/block/extension.rs index 56b00893da..2567df6f2a 100644 --- a/sync/src/block/extension.rs +++ b/sync/src/block/extension.rs @@ -444,9 +444,8 @@ impl NetworkExtension for Extension { if let Some(root) = restore.next_to_feed() { self.send_chunk_request(&block, &root); } else { - cdebug!(SYNC, "Transitioning state to {:?}", State::Full); self.client.force_update_best_block(&block); - self.state = State::Full; + self.transition_to_full(); } } State::Full => { @@ -1037,12 +1036,20 @@ impl Extension { if let Some(root) = restore.next_to_feed() { self.send_chunk_request(&block, &root); } else { - cdebug!(SYNC, "Transitioning state to {:?}", State::Full); self.client.force_update_best_block(&block); - self.state = State::Full; + self.transition_to_full(); } } } + + fn transition_to_full(&mut self) { + cdebug!(SYNC, "Transitioning state to {:?}", State::Full); + let best_hash = self.client.best_block_header().hash(); + for downloader in self.header_downloaders.values_mut() { + downloader.update_pivot(best_hash); + } + self.state = State::Full; + } } pub struct BlockSyncSender(EventSender);