Skip to content

Commit

Permalink
Remove request ID from the new protocol (paritytech#5049)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka authored and General-Beck committed Mar 4, 2020
1 parent cc7142c commit 9d08f54
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 147 deletions.
13 changes: 6 additions & 7 deletions client/network/src/protocol/block_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Config {
let mut v = Vec::new();
v.extend_from_slice(b"/");
v.extend_from_slice(id.as_bytes());
v.extend_from_slice(b"/sync/1");
v.extend_from_slice(b"/sync/2");
self.protocol = v.into();
self
}
Expand Down Expand Up @@ -146,8 +146,7 @@ where
, request: &api::v1::BlockRequest
) -> Result<api::v1::BlockResponse, Error>
{
log::trace!("block request {} from peer {}: from block {:?} to block {:?}, max blocks {:?}",
request.id,
log::trace!("block request from peer {}: from block {:?} to block {:?}, max blocks {:?}",
peer,
request.from_block,
request.to_block,
Expand Down Expand Up @@ -242,7 +241,7 @@ where
}
}

Ok(api::v1::BlockResponse { id: request.id, blocks })
Ok(api::v1::BlockResponse { blocks })
}
}

Expand Down Expand Up @@ -274,10 +273,10 @@ where
fn inject_node_event(&mut self, peer: PeerId, Request(request, mut stream): Request<NegotiatedSubstream>) {
match self.on_block_request(&peer, &request) {
Ok(res) => {
log::trace!("enqueueing block response {} for peer {} with {} blocks", res.id, peer, res.blocks.len());
log::trace!("enqueueing block response for peer {} with {} blocks", peer, res.blocks.len());
let mut data = Vec::with_capacity(res.encoded_len());
if let Err(e) = res.encode(&mut data) {
log::debug!("error encoding block response {} for peer {}: {}", res.id, peer, e)
log::debug!("error encoding block response for peer {}: {}", peer, e)
} else {
let future = async move {
if let Err(e) = write_one(&mut stream, data).await {
Expand All @@ -287,7 +286,7 @@ where
self.outgoing.push(future.boxed())
}
}
Err(e) => log::debug!("error handling block request {} from peer {}: {}", request.id, peer, e)
Err(e) => log::debug!("error handling block request from peer {}: {}", peer, e)
}
}

Expand Down
Loading

0 comments on commit 9d08f54

Please sign in to comment.