From 9189539715d0f1d6c4944ece34d276c15f5eff9b Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Tue, 4 Jan 2022 10:31:45 +0100 Subject: [PATCH] Use BufReader internally in StreamReader to avoid performance regression on existing callers --- src/network/stream_reader.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/stream_reader.rs b/src/network/stream_reader.rs index 3becfabc..6d07ef66 100644 --- a/src/network/stream_reader.rs +++ b/src/network/stream_reader.rs @@ -23,14 +23,14 @@ //! use core::fmt; -use io::Read; +use io::{Read, BufReader}; use consensus::{encode, Decodable}; /// Struct used to configure stream reader function pub struct StreamReader { /// Stream to read from - pub stream: R, + pub stream: BufReader, } impl fmt::Debug for StreamReader { @@ -44,7 +44,7 @@ impl StreamReader { #[deprecated(since="0.28.0", note="wrap you stream into a buffered reader if necessary and use consensus_encode directly")] pub fn new(stream: R, _buffer_size: Option) -> StreamReader { StreamReader { - stream, + stream: BufReader::new(stream), } }