Stop relying on `Take`'s `by_ref` method

This commit is contained in:
Matt Corallo 2023-09-11 17:56:57 +00:00
parent 2364e1a877
commit 7395093f94
3 changed files with 4 additions and 4 deletions

View File

@ -320,7 +320,7 @@ pub trait Decodable: Sized {
/// instead. /// instead.
#[inline] #[inline]
fn consensus_decode<R: io::Read + ?Sized>(reader: &mut R) -> Result<Self, Error> { fn consensus_decode<R: io::Read + ?Sized>(reader: &mut R) -> Result<Self, Error> {
Self::consensus_decode_from_finite_reader(reader.take(MAX_VEC_SIZE as u64).by_ref()) Self::consensus_decode_from_finite_reader(&mut reader.take(MAX_VEC_SIZE as u64))
} }
} }

View File

@ -37,7 +37,7 @@ macro_rules! impl_consensus_encoding {
use crate::io::Read as _; use crate::io::Read as _;
let mut r = r.take($crate::consensus::encode::MAX_VEC_SIZE as u64); let mut r = r.take($crate::consensus::encode::MAX_VEC_SIZE as u64);
Ok($thing { Ok($thing {
$($field: $crate::consensus::Decodable::consensus_decode(r.by_ref())?),+ $($field: $crate::consensus::Decodable::consensus_decode(&mut r)?),+
}) })
} }
} }

View File

@ -429,7 +429,7 @@ impl Decodable for HeaderDeserializationWrapper {
#[inline] #[inline]
fn consensus_decode<R: io::Read + ?Sized>(r: &mut R) -> Result<Self, encode::Error> { fn consensus_decode<R: io::Read + ?Sized>(r: &mut R) -> Result<Self, encode::Error> {
Self::consensus_decode_from_finite_reader(r.take(MAX_MSG_SIZE as u64).by_ref()) Self::consensus_decode_from_finite_reader(&mut r.take(MAX_MSG_SIZE as u64))
} }
} }
@ -534,7 +534,7 @@ impl Decodable for RawNetworkMessage {
#[inline] #[inline]
fn consensus_decode<R: io::Read + ?Sized>(r: &mut R) -> Result<Self, encode::Error> { fn consensus_decode<R: io::Read + ?Sized>(r: &mut R) -> Result<Self, encode::Error> {
Self::consensus_decode_from_finite_reader(r.take(MAX_MSG_SIZE as u64).by_ref()) Self::consensus_decode_from_finite_reader(&mut r.take(MAX_MSG_SIZE as u64))
} }
} }