aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc
diff options
context:
space:
mode:
authorhozan23 <hozan23@proton.me>2023-11-20 23:25:29 +0300
committerhozan23 <hozan23@proton.me>2023-11-20 23:25:29 +0300
commit8779a0e714367e7c3b576e39c753f85a45514bf3 (patch)
tree85333dfebed0e609093a73074d64f2e6ee69584f /jsonrpc
parent598f9e2d47da80f2bec2ead9c2fe215eff157936 (diff)
jsonrpc/codec: rename `max_allowed_msg_size` to `max_allowed_buffer_size`
Diffstat (limited to 'jsonrpc')
-rw-r--r--jsonrpc/src/client.rs4
-rw-r--r--jsonrpc/src/codec.rs14
2 files changed, 9 insertions, 9 deletions
diff --git a/jsonrpc/src/client.rs b/jsonrpc/src/client.rs
index d5caebe..1ce9ecb 100644
--- a/jsonrpc/src/client.rs
+++ b/jsonrpc/src/client.rs
@@ -25,7 +25,7 @@ impl Client {
/// Creates a new RPC client.
pub fn new(conn: Conn, config: ClientConfig) -> Self {
let codec_config = CodecConfig {
- max_allowed_msg_size: 0,
+ max_allowed_buffer_size: 0,
..Default::default()
};
let codec = Codec::new(conn, codec_config);
@@ -36,7 +36,7 @@ impl Client {
pub async fn new_with_endpoint(endpoint: &Endpoint, config: ClientConfig) -> Result<Self> {
let conn = dial(endpoint).await?;
let codec_config = CodecConfig {
- max_allowed_msg_size: 0,
+ max_allowed_buffer_size: 0,
..Default::default()
};
let codec = Codec::new(conn, codec_config);
diff --git a/jsonrpc/src/codec.rs b/jsonrpc/src/codec.rs
index ea97e54..41fed06 100644
--- a/jsonrpc/src/codec.rs
+++ b/jsonrpc/src/codec.rs
@@ -6,7 +6,7 @@ use karyons_net::Conn;
use crate::{Error, Result};
const DEFAULT_BUFFER_SIZE: usize = 1024;
-const DEFAULT_MAX_ALLOWED_MSG_SIZE: usize = 1024 * 1024; // 1MB
+const DEFAULT_MAX_ALLOWED_BUFFER_SIZE: usize = 1024 * 1024; // 1MB
// TODO: Add unit tests for Codec's functions.
@@ -14,16 +14,16 @@ const DEFAULT_MAX_ALLOWED_MSG_SIZE: usize = 1024 * 1024; // 1MB
#[derive(Clone)]
pub struct CodecConfig {
pub default_buffer_size: usize,
- /// The maximum allowed size to receive a message. If set to zero, there
- /// will be no size limit.
- pub max_allowed_msg_size: usize,
+ /// The maximum allowed buffer size to receive a message. If set to zero,
+ /// there will be no size limit.
+ pub max_allowed_buffer_size: usize,
}
impl Default for CodecConfig {
fn default() -> Self {
Self {
default_buffer_size: DEFAULT_BUFFER_SIZE,
- max_allowed_msg_size: DEFAULT_MAX_ALLOWED_MSG_SIZE,
+ max_allowed_buffer_size: DEFAULT_MAX_ALLOWED_BUFFER_SIZE,
}
}
}
@@ -67,8 +67,8 @@ impl Codec {
}
}
- if self.config.max_allowed_msg_size != 0
- && buffer.len() == self.config.max_allowed_msg_size
+ if self.config.max_allowed_buffer_size != 0
+ && buffer.len() == self.config.max_allowed_buffer_size
{
return Err(Error::InvalidMsg(
"Message exceeds the maximum allowed size",