Skip to content

Commit

Permalink
refactor(noise): modify message framing
Browse files Browse the repository at this point in the history
Resolves #4488.

Pull-Request: #4548.
  • Loading branch information
0xcrust authored Oct 26, 2023
1 parent 51dd702 commit 4d2983b
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 424 deletions.
38 changes: 26 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions transports/noise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

[dependencies]
asynchronous-codec = "0.7"
bytes = "1"
curve25519-dalek = "4.1.1"
futures = "0.3.28"
Expand Down
9 changes: 5 additions & 4 deletions transports/noise/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
mod framed;
pub(crate) mod handshake;
use asynchronous_codec::Framed;
use bytes::Bytes;
use framed::{NoiseFramed, MAX_FRAME_LEN};
use framed::{Codec, MAX_FRAME_LEN};
use futures::prelude::*;
use futures::ready;
use log::trace;
Expand All @@ -38,7 +39,7 @@ use std::{
///
/// `T` is the type of the underlying I/O resource.
pub struct Output<T> {
io: NoiseFramed<T, snow::TransportState>,
io: Framed<T, Codec<snow::TransportState>>,
recv_buffer: Bytes,
recv_offset: usize,
send_buffer: Vec<u8>,
Expand All @@ -47,12 +48,12 @@ pub struct Output<T> {

impl<T> fmt::Debug for Output<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("NoiseOutput").field("io", &self.io).finish()
f.debug_struct("NoiseOutput").finish()
}
}

impl<T> Output<T> {
fn new(io: NoiseFramed<T, snow::TransportState>) -> Self {
fn new(io: Framed<T, Codec<snow::TransportState>>) -> Self {
Output {
io,
recv_buffer: Bytes::new(),
Expand Down
Loading

0 comments on commit 4d2983b

Please sign in to comment.