From df6cab7274210ab434e753764fa6cb77be2fdbfb Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Fri, 13 Dec 2024 14:35:48 +0800 Subject: [PATCH] Send multi continuous Headers --- sync/src/synchronizer/get_headers_process.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sync/src/synchronizer/get_headers_process.rs b/sync/src/synchronizer/get_headers_process.rs index 12c5041413..3445f55c07 100644 --- a/sync/src/synchronizer/get_headers_process.rs +++ b/sync/src/synchronizer/get_headers_process.rs @@ -74,18 +74,18 @@ impl<'a> GetHeadersProcess<'a> { ); self.synchronizer.peers().getheaders_received(self.peer); - let headers: Vec = - active_chain.get_locator_response(block_number, &hash_stop); + let headers_vec: Vec> = + active_chain.get_locator_responses(block_number, &hash_stop); // response headers - debug!("headers len={}", headers.len()); - - let content = packed::SendHeaders::new_builder() - .headers(headers.into_iter().map(|x| x.data()).pack()) - .build(); - let message = packed::SyncMessage::new_builder().set(content).build(); - - attempt!(send_message_to(self.nc, self.peer, &message)); + debug!("headers len={}", headers_vec.len()); + for headers in headers_vec { + let content = packed::SendHeaders::new_builder() + .headers(headers.into_iter().map(|x| x.data()).pack()) + .build(); + let message = packed::SyncMessage::new_builder().set(content).build(); + attempt!(send_message_to(self.nc, self.peer, &message)); + } } else { return StatusCode::GetHeadersMissCommonAncestors .with_context(format!("{block_locator_hashes:#x?}"));