X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fser.rs;h=b718e228c93e8233ce799e7fa10c90b26cd89b9d;hb=52edab7055e998ec334855c9979403e0d8eb9406;hp=961d4f1020073f8d76553374ef0cec394e217828;hpb=253af8dd617161b2bd79173f9da3ecc0b0991f7e;p=rust-lightning diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 961d4f10..b718e228 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -31,7 +31,8 @@ use util::byte_utils; use util::byte_utils::{be64_to_array, be48_to_array, be32_to_array, be16_to_array, slice_to_be16, slice_to_be32, slice_to_be48, slice_to_be64}; -const MAX_BUF_SIZE: usize = 64 * 1024; +/// serialization buffer size +pub const MAX_BUF_SIZE: usize = 64 * 1024; /// A trait that is similar to std::io::Write but has one extra function which can be used to size /// buffers being written into. @@ -706,8 +707,7 @@ macro_rules! impl_consensus_ser { fn write(&self, writer: &mut W) -> Result<(), ::std::io::Error> { match self.consensus_encode(WriterWriteAdaptor(writer)) { Ok(_) => Ok(()), - Err(consensus::encode::Error::Io(e)) => Err(e), - Err(_) => panic!("We shouldn't get a consensus::encode::Error unless our Write generated an std::io::Error"), + Err(e) => Err(e), } } } @@ -717,7 +717,7 @@ macro_rules! impl_consensus_ser { match consensus::encode::Decodable::consensus_decode(r) { Ok(t) => Ok(t), Err(consensus::encode::Error::Io(ref e)) if e.kind() == ::std::io::ErrorKind::UnexpectedEof => Err(DecodeError::ShortRead), - Err(consensus::encode::Error::Io(e)) => Err(DecodeError::Io(e)), + Err(consensus::encode::Error::Io(e)) => Err(DecodeError::Io(e.kind())), Err(_) => Err(DecodeError::InvalidValue), } }