monero-p2p: tell client message was sent after sending message.

Otherwise, the message might not be sent
This commit is contained in:
Boog900 2024-01-13 15:56:22 +00:00
parent f7149863ae
commit 0cc2acc816
No known key found for this signature in database
GPG key ID: 5401367FB7302004
2 changed files with 10 additions and 4 deletions

View file

@ -15,7 +15,6 @@
//! A tokio-codec for levin buckets
use std::io::ErrorKind;
use std::marker::PhantomData;
use bytes::{Buf, BufMut, BytesMut};

View file

@ -97,11 +97,18 @@ where
request_id: req.request.id(),
tx: req.response_channel,
};
self.send_message_to_peer(req.request.into()).await?;
} else {
let res = self.send_message_to_peer(req.request.into()).await;
if let Err(e) = res {
let err_str = e.to_string();
let _ = req.response_channel.send(Err(err_str.clone().into()));
Err(e)?
} else {
// TODO: we should send this after sending the message to the peer.
req.response_channel.send(Ok(PeerResponse::NA));
}
self.send_message_to_peer(req.request.into()).await
}
Ok(())
}
async fn handle_peer_request(&mut self, req: PeerRequest) -> Result<(), PeerError> {