Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
zsluedem committed Oct 13, 2023
1 parent 39d011b commit 0d3a66f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/p2p/src/request_response/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use futures::{AsyncReadExt, AsyncWriteExt, FutureExt};
use libp2p::swarm::Stream;
use libp2p::{core::UpgradeInfo, InboundUpgrade};
use ssz_rs::Deserialize;
use tracing::trace;

use super::models::{
BoundError, GetMetaData, GoodbyeReason, Ping, PooledUserOpHashesReq, PooledUserOpsByHashReq,
Expand Down Expand Up @@ -44,7 +45,7 @@ impl InboundUpgrade<Stream> for InboundContainer {
.take(REQUEST_SIZE_MAXIMUM)
.read_to_end(&mut data)
.await?;

trace!("Received {} bytes", data.len());
if data.is_empty() {
Err(BoundError::IoError(io::Error::new(
std::io::ErrorKind::UnexpectedEof,
Expand Down
4 changes: 4 additions & 0 deletions crates/p2p/src/request_response/outbound.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use futures::{future::BoxFuture, AsyncReadExt, AsyncWriteExt, FutureExt};
use libp2p::{core::UpgradeInfo, OutboundUpgrade, Stream};
use ssz_rs::{Deserialize, Serialize};
use tracing::{debug, trace};

use super::{
models::{
Expand All @@ -23,6 +24,7 @@ impl UpgradeInfo for OutboundContainer {
type Info = ProtocolId;
type InfoIter = Vec<Self::Info>;
fn protocol_info(&self) -> Self::InfoIter {
debug!("protocol_info {:?}", self.request);
match self.request {
Request::Status(_) => vec![ProtocolId::new(Protocol::Status)],
Request::GoodbyeReason(_) => vec![ProtocolId::new(Protocol::Goodbye)],
Expand Down Expand Up @@ -60,6 +62,7 @@ impl OutboundUpgrade<Stream> for OutboundContainer {
}
};
let compressed = snap::raw::Encoder::new().compress_vec(&buffer)?;
trace!("Sending {:?} bytes", compressed);
socket_mut.write_all(&compressed).await?;
socket_mut.close().await?;

Expand All @@ -69,6 +72,7 @@ impl OutboundUpgrade<Stream> for OutboundContainer {
.read_to_end(&mut comressed_response)
.await?;
let decompressed = snap::raw::Decoder::new().decompress_vec(&comressed_response)?;
trace!("Received {:?} bytes", decompressed);
let response = match info.message_name {
Protocol::Status => Response::Status(Status::deserialize(&decompressed)?),
Protocol::Goodbye => {
Expand Down

0 comments on commit 0d3a66f

Please sign in to comment.