mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
Move the legacy protocol handshake to the legacy substream (#5938)
* Move the legacy protocol handshake to the legacy substream * Fix tests * Remove line that wasn't supposed to be committed * Remove hack * Rework how it's done * Some little changes * update_chain wasn't doing its thing * Fix service tests not calling update_chain * Update client/network/src/protocol/generic_proto/behaviour.rs Co-authored-by: Max Inden <mail@max-inden.de> * [WIP] * Revert "[WIP]" This reverts commit 2b892e6a7637c0b1297e6ecdbb919321c9098ff5. * Update client/network/src/protocol.rs Co-authored-by: Max Inden <mail@max-inden.de> * Fix received message not being handshake * Update client/network/src/protocol/generic_proto/behaviour.rs Co-authored-by: Max Inden <mail@max-inden.de> Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@@ -248,7 +248,7 @@ impl ProtocolName for RegisteredProtocolName {
|
||||
impl<TSubstream> InboundUpgrade<TSubstream> for RegisteredProtocol
|
||||
where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
{
|
||||
type Output = RegisteredProtocolSubstream<TSubstream>;
|
||||
type Output = (RegisteredProtocolSubstream<TSubstream>, Vec<u8>);
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, io::Error>> + Send>>;
|
||||
type Error = io::Error;
|
||||
|
||||
@@ -266,8 +266,10 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
|
||||
let handshake = BytesMut::from(&self.handshake_message.read()[..]);
|
||||
framed.send(handshake).await?;
|
||||
let received_handshake = framed.next().await
|
||||
.ok_or_else(|| io::ErrorKind::UnexpectedEof)??;
|
||||
|
||||
Ok(RegisteredProtocolSubstream {
|
||||
Ok((RegisteredProtocolSubstream {
|
||||
is_closing: false,
|
||||
endpoint: Endpoint::Listener,
|
||||
send_queue: VecDeque::new(),
|
||||
@@ -275,7 +277,7 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
inner: framed.fuse(),
|
||||
protocol_version: info.version,
|
||||
clogged_fuse: false,
|
||||
})
|
||||
}, received_handshake.to_vec()))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -301,8 +303,12 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
|
||||
let handshake = BytesMut::from(&self.handshake_message.read()[..]);
|
||||
framed.send(handshake).await?;
|
||||
let received_handshake = framed.next().await
|
||||
.ok_or_else(|| {
|
||||
io::Error::new(io::ErrorKind::UnexpectedEof, "Failed to receive handshake")
|
||||
})??;
|
||||
|
||||
Ok(RegisteredProtocolSubstream {
|
||||
Ok((RegisteredProtocolSubstream {
|
||||
is_closing: false,
|
||||
endpoint: Endpoint::Dialer,
|
||||
send_queue: VecDeque::new(),
|
||||
@@ -310,7 +316,7 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
inner: framed.fuse(),
|
||||
protocol_version: info.version,
|
||||
clogged_fuse: false,
|
||||
})
|
||||
}, received_handshake.to_vec()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user