($stream: expr, {$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}) => { {
use ln::msgs::DecodeError;
let mut last_seen_type: Option<u64> = None;
+ let mut stream_ref = $stream;
'tlv_read: loop {
use util::ser;
// determine whether we should break or return ShortRead if we get an
// UnexpectedEof. This should in every case be largely cosmetic, but its nice to
// pass the TLV test vectors exactly, which requre this distinction.
- let mut tracking_reader = ser::ReadTrackingReader::new($stream);
+ let mut tracking_reader = ser::ReadTrackingReader::new(&mut stream_ref);
match ser::Readable::read(&mut tracking_reader) {
Err(DecodeError::ShortRead) => {
if !tracking_reader.have_read {
last_seen_type = Some(typ.0);
// Finally, read the length and value itself:
- let length: ser::BigSize = ser::Readable::read($stream)?;
- let mut s = ser::FixedLengthReader::new($stream, length.0);
+ let length: ser::BigSize = ser::Readable::read(&mut stream_ref)?;
+ let mut s = ser::FixedLengthReader::new(&mut stream_ref, length.0);
match typ.0 {
$($type => {
decode_tlv!(s, $field, $fieldty);