mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 10:47:55 +00:00
Fix sync logging (#5879)
This commit is contained in:
@@ -751,7 +751,7 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
|
||||
None
|
||||
};
|
||||
let block_data = message::generic::BlockData {
|
||||
hash: hash,
|
||||
hash,
|
||||
header: if get_header { Some(header) } else { None },
|
||||
body: if get_body {
|
||||
self.context_data
|
||||
@@ -783,7 +783,7 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
|
||||
}
|
||||
let response = message::generic::BlockResponse {
|
||||
id: request.id,
|
||||
blocks: blocks,
|
||||
blocks,
|
||||
};
|
||||
trace!(target: "sync", "Sending BlockResponse with {} blocks", response.blocks.len());
|
||||
self.send_message(&peer, None, GenericMessage::BlockResponse(response))
|
||||
|
||||
@@ -536,20 +536,25 @@ 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, mut 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() {
|
||||
debug!(
|
||||
target: "sync",
|
||||
"Explicit sync request for block {:?} with no peers specified. \
|
||||
Syncing from all connected peers {:?} instead.",
|
||||
hash, peers,
|
||||
);
|
||||
|
||||
peers = self.peers.iter()
|
||||
// Only request blocks from peers who are ahead or on a par.
|
||||
.filter(|(_, peer)| peer.best_number >= number)
|
||||
.map(|(id, _)| id.clone())
|
||||
.collect();
|
||||
|
||||
debug!(
|
||||
target: "sync",
|
||||
"Explicit sync request for block {:?} with no peers specified. \
|
||||
Syncing from these peers {:?} instead.",
|
||||
hash, peers,
|
||||
);
|
||||
} else {
|
||||
debug!(target: "sync", "Explicit sync request for block {:?} with {:?}", hash, peers);
|
||||
}
|
||||
@@ -653,12 +658,10 @@ impl<B: BlockT> ChainSync<B> {
|
||||
let pending_requests = self.pending_requests.take();
|
||||
let max_parallel = if major_sync { 1 } else { self.max_parallel_downloads };
|
||||
let iter = self.peers.iter_mut().filter_map(move |(id, peer)| {
|
||||
if !peer.state.is_available() {
|
||||
return None
|
||||
}
|
||||
if !pending_requests.contains(id) {
|
||||
if !peer.state.is_available() || !pending_requests.contains(id) {
|
||||
return None
|
||||
}
|
||||
|
||||
if let Some((range, req)) = peer_block_request(
|
||||
id,
|
||||
peer,
|
||||
|
||||
Reference in New Issue
Block a user