mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
make sure we use BigEndian when reading numbers via StreamingReader (#2821)
This commit is contained in:
parent
59db5e3bd1
commit
4ba7b0a46a
1 changed files with 6 additions and 6 deletions
|
@ -393,32 +393,32 @@ impl<'a> StreamingReader<'a> {
|
||||||
impl<'a> Reader for StreamingReader<'a> {
|
impl<'a> Reader for StreamingReader<'a> {
|
||||||
fn read_u8(&mut self) -> Result<u8, Error> {
|
fn read_u8(&mut self) -> Result<u8, Error> {
|
||||||
let buf = self.read_fixed_bytes(1)?;
|
let buf = self.read_fixed_bytes(1)?;
|
||||||
deserialize(&mut &buf[..])
|
Ok(buf[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_u16(&mut self) -> Result<u16, Error> {
|
fn read_u16(&mut self) -> Result<u16, Error> {
|
||||||
let buf = self.read_fixed_bytes(2)?;
|
let buf = self.read_fixed_bytes(2)?;
|
||||||
deserialize(&mut &buf[..])
|
Ok(BigEndian::read_u16(&buf[..]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_u32(&mut self) -> Result<u32, Error> {
|
fn read_u32(&mut self) -> Result<u32, Error> {
|
||||||
let buf = self.read_fixed_bytes(4)?;
|
let buf = self.read_fixed_bytes(4)?;
|
||||||
deserialize(&mut &buf[..])
|
Ok(BigEndian::read_u32(&buf[..]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_i32(&mut self) -> Result<i32, Error> {
|
fn read_i32(&mut self) -> Result<i32, Error> {
|
||||||
let buf = self.read_fixed_bytes(4)?;
|
let buf = self.read_fixed_bytes(4)?;
|
||||||
deserialize(&mut &buf[..])
|
Ok(BigEndian::read_i32(&buf[..]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_u64(&mut self) -> Result<u64, Error> {
|
fn read_u64(&mut self) -> Result<u64, Error> {
|
||||||
let buf = self.read_fixed_bytes(8)?;
|
let buf = self.read_fixed_bytes(8)?;
|
||||||
deserialize(&mut &buf[..])
|
Ok(BigEndian::read_u64(&buf[..]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_i64(&mut self) -> Result<i64, Error> {
|
fn read_i64(&mut self) -> Result<i64, Error> {
|
||||||
let buf = self.read_fixed_bytes(8)?;
|
let buf = self.read_fixed_bytes(8)?;
|
||||||
deserialize(&mut &buf[..])
|
Ok(BigEndian::read_i64(&buf[..]))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read a variable size vector from the underlying stream. Expects a usize
|
/// Read a variable size vector from the underlying stream. Expects a usize
|
||||||
|
|
Loading…
Reference in a new issue