use ln::msgs::DecodeError;
use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
use routing::network_graph::NetworkUpdate;
-use util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, VecReadWrapper, VecWriteWrapper};
+use util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, VecReadWrapper, IterWriteWrapper};
use routing::router::{RouteHop, RouteParameters};
use bitcoin::Transaction;
&Event::SpendableOutputs { ref outputs } => {
5u8.write(writer)?;
write_tlv_fields!(writer, {
- (0, VecWriteWrapper(outputs), required),
+ (0, IterWriteWrapper(outputs.iter()), required),
});
},
&Event::PaymentForwarded { fee_earned_msat, claim_from_onchain_tx } => {
}
}
-/// Wrapper to write each element of a Vec with no length prefix
-pub(crate) struct VecWriteWrapper<'a, T: Writeable>(pub &'a Vec<T>);
-impl<'a, T: Writeable> Writeable for VecWriteWrapper<'a, T> {
+/// Wrapper to write each element of an iterator with no length prefix
+pub(crate) struct IterWriteWrapper<I: Iterator + Clone>(pub I) where I::Item: Writeable;
+impl<I: Iterator + Clone> Writeable for IterWriteWrapper<I> where I::Item: Writeable {
#[inline]
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
- for ref v in self.0.iter() {
+ for v in self.0.clone() {
v.write(writer)?;
}
Ok(())
$field.write($stream)?;
};
($stream: expr, $type: expr, $field: expr, vec_type) => {
- encode_tlv!($stream, $type, ::util::ser::VecWriteWrapper(&$field), required);
+ encode_tlv!($stream, $type, ::util::ser::IterWriteWrapper($field.iter()), required);
};
($stream: expr, $optional_type: expr, $optional_field: expr, option) => {
if let Some(ref field) = $optional_field {
$len.0 += field_len;
};
($len: expr, $type: expr, $field: expr, vec_type) => {
- get_varint_length_prefixed_tlv_length!($len, $type, ::util::ser::VecWriteWrapper(&$field), required);
+ get_varint_length_prefixed_tlv_length!($len, $type, ::util::ser::IterWriteWrapper($field.iter()), required);
};
($len: expr, $optional_type: expr, $optional_field: expr, option) => {
if let Some(ref field) = $optional_field {