Skip to content

Commit

Permalink
refactor(network): Modify max frame length for transmission. (nervosn…
Browse files Browse the repository at this point in the history
  • Loading branch information
yejiayu authored Jun 10, 2019
1 parent a5cdf59 commit de57a5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ core-serialization = { path = "../serialization" }
core-runtime = { path = "../runtime" }
core-types = { path = "../types" }

tokio = "0.1"
tentacle = "0.2"
tentacle-discovery = "0.2"
log = "0.4"
Expand Down
9 changes: 9 additions & 0 deletions core/network/src/p2p/protocol/transmission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use tentacle::context::{ProtocolContext, ProtocolContextMutRef};
use tentacle::service::{ProtocolHandle, ProtocolMeta};
use tentacle::{builder::MetaBuilder, bytes::Bytes, traits::ServiceProtocol};
use tentacle::{multiaddr::Multiaddr, ProtocolId, SessionId};
use tokio::codec::LengthDelimitedCodec;

use common_channel::Sender;

Expand All @@ -24,6 +25,8 @@ pub const PROTOCOL_NAME: &str = "transmission";
/// Protocol support versions
pub const SUPPORT_VERSIONS: [&str; 1] = ["0.2"];

const MAX_FRAME_LENGTH: usize = 1024 * 1024 * 100;

pub struct SessionMessage {
pub id: SessionId,
pub addr: Multiaddr,
Expand All @@ -49,6 +52,12 @@ impl TransmissionProtocol {
.name(name!(PROTOCOL_NAME))
.support_versions(support_versions!(SUPPORT_VERSIONS))
.service_handle(service_handle)
.codec(|| {
let mut codec = LengthDelimitedCodec::new();
codec.set_max_frame_length(MAX_FRAME_LENGTH);

Box::new(codec)
})
.build()
}
}
Expand Down

0 comments on commit de57a5e

Please sign in to comment.