Skip to content

Commit

Permalink
Added a maximum frame length constant for a framed substream, so it c…
Browse files Browse the repository at this point in the history
…an be visible in the Tari code and not dependent on the default frame size.
  • Loading branch information
hansieodendaal committed Jun 2, 2020
1 parent 1a3009b commit da6b8d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion comms/src/protocol/messaging/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const MAX_SEND_RETRIES: usize = 1;
/// The maximum amount of inbound messages to accept within the `RATE_LIMIT_RESTOCK_INTERVAL` window
const RATE_LIMIT_CAPACITY: usize = 10;
const RATE_LIMIT_RESTOCK_INTERVAL: Duration = Duration::from_millis(100);
const MAX_FRAME_LENGTH_MB: usize = 8;

pub type MessagingEventSender = broadcast::Sender<Arc<MessagingEvent>>;
pub type MessagingEventReceiver = broadcast::Receiver<Arc<MessagingEvent>>;
Expand Down Expand Up @@ -205,7 +206,9 @@ impl MessagingProtocol {

pub fn framed<TSubstream>(socket: TSubstream) -> Framed<IoCompat<TSubstream>, LengthDelimitedCodec>
where TSubstream: AsyncRead + AsyncWrite + Unpin {
Framed::new(IoCompat::new(socket), LengthDelimitedCodec::new())
let mut codec = LengthDelimitedCodec::new();
codec.set_max_frame_length(MAX_FRAME_LENGTH_MB * 1_024 * 1_024);
Framed::new(IoCompat::new(socket), codec)
}

async fn handle_internal_messaging_event(&mut self, event: MessagingEvent) {
Expand Down

0 comments on commit da6b8d4

Please sign in to comment.