Skip to content

Commit

Permalink
remove beetswap error prefix in messages
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique committed Jun 11, 2024
1 parent 1f5ee85 commit 1dc2c17
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/cid_prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl CidPrefix {
) -> Result<CidGeneric<S>, MultihasherError> {
if self.multihash_size > S {
debug!(
"beetswap error: Multihash<{}> can not hold multihash of size {}",
"Multihash<{}> can not hold multihash of size {}",
S, self.multihash_size
);
return Err(MultihasherError::InvalidMultihashSize);
Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ impl<const S: usize> ClientConnectionHandler<S> {
}

fn close_sink_on_error(&mut self, location: &str) {
debug!("beetswap error: sink operation failed, closing: {location}");
debug!("sink operation failed, closing: {location}");
self.sink_state = SinkState::None;
}

Expand Down
18 changes: 6 additions & 12 deletions src/incoming_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<const S: usize> futures_core::stream::Stream for IncomingStream<S> {
let msg = match self.stream.poll_next_unpin(cx) {
Poll::Ready(Some(Ok(msg))) => msg,
Poll::Ready(Some(Err(e))) => {
debug!("beetswap error: Message decoding failed: {e}");
debug!("Message decoding failed: {e}");
return Poll::Ready(None);
}
Poll::Ready(None) => return Poll::Ready(None),
Expand Down Expand Up @@ -116,10 +116,7 @@ async fn process_message<const S: usize>(
let cid = match CidGeneric::try_from(&block_presence.cid[..]) {
Ok(cid) => cid,
Err(e) => {
debug!(
"beetswap error: Invalid CID bytes: {}: {:?}",
e, block_presence.cid
);
debug!("Invalid CID bytes: {}: {:?}", e, block_presence.cid);
return None;
}
};
Expand All @@ -133,29 +130,26 @@ async fn process_message<const S: usize>(

for payload in msg.payload {
let Some(cid_prefix) = CidPrefix::from_bytes(&payload.prefix) else {
debug!(
"beeswap error: block.prefix not decodable: {:?}",
payload.prefix
);
debug!("block.prefix not decodable: {:?}", payload.prefix);
return None;
};

let cid = match cid_prefix.to_cid(&multihasher, &payload.data).await {
Ok(cid) => cid,
Err(MultihasherError::UnknownMultihashCode) => {
debug!(
"beetswap error: Multihasher non-fatal error: Unknown multihash code: {}",
"Multihasher non-fatal error: Unknown multihash code: {}",
cid_prefix.multihash_code()
);
continue;
}
Err(MultihasherError::Custom(e)) => {
debug!("beetswap error: Multihasher non-fatal error: {e}");
debug!("Multihasher non-fatal error: {e}");
continue;
}
// Any other error is fatal and we need to close the stream.
Err(e) => {
debug!("beetswap error: Multihasher fatal error: {e}");
debug!("Multihasher fatal error: {e}");
return None;
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ where
self.outgoing_queue.push_back((cid, data));
}
Err(e) => {
debug!("beetswap error: Fetching {cid} from blockstore failed: {e}");
debug!("Fetching {cid} from blockstore failed: {e}");
}
}
}
Expand Down Expand Up @@ -393,7 +393,7 @@ impl<const S: usize> ServerConnectionHandler<S> {
}

fn close_sink_on_error(&mut self, location: &str) {
debug!("beetswap error: sink operation failed, closing: {location}");
debug!("sink operation failed, closing: {location}");
self.sink = SinkState::None;
}

Expand Down

0 comments on commit 1dc2c17

Please sign in to comment.