mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Increase read buffer size
Our messages are quite big, increase the read buffer to 1 megabyte to accommodate them.
This commit is contained in:
parent
be37725303
commit
2bd4977fe4
@ -13,6 +13,9 @@ use xmr_btc::{alice, bob, monero};
|
|||||||
/// Time to wait for a response back once we send a request.
|
/// Time to wait for a response back once we send a request.
|
||||||
pub const TIMEOUT: u64 = 3600; // One hour.
|
pub const TIMEOUT: u64 = 3600; // One hour.
|
||||||
|
|
||||||
|
/// Message receive buffer.
|
||||||
|
const BUF_SIZE: usize = 1024 * 1024;
|
||||||
|
|
||||||
// TODO: Think about whether there is a better way to do this, e.g., separate
|
// TODO: Think about whether there is a better way to do this, e.g., separate
|
||||||
// Codec for each Message and a macro that implements them.
|
// Codec for each Message and a macro that implements them.
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ impl RequestResponseCodec for Codec {
|
|||||||
where
|
where
|
||||||
T: AsyncRead + Unpin + Send,
|
T: AsyncRead + Unpin + Send,
|
||||||
{
|
{
|
||||||
let message = upgrade::read_one(io, 1024)
|
let message = upgrade::read_one(io, BUF_SIZE)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
||||||
let mut de = serde_json::Deserializer::from_slice(&message);
|
let mut de = serde_json::Deserializer::from_slice(&message);
|
||||||
@ -79,7 +82,7 @@ impl RequestResponseCodec for Codec {
|
|||||||
where
|
where
|
||||||
T: AsyncRead + Unpin + Send,
|
T: AsyncRead + Unpin + Send,
|
||||||
{
|
{
|
||||||
let message = upgrade::read_one(io, 1024)
|
let message = upgrade::read_one(io, BUF_SIZE)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
||||||
let mut de = serde_json::Deserializer::from_slice(&message);
|
let mut de = serde_json::Deserializer::from_slice(&message);
|
||||||
|
Loading…
Reference in New Issue
Block a user