X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Frouting%2Frouter.rs;fp=lightning%2Fsrc%2Frouting%2Frouter.rs;h=77969ae9d96b2f43c9af7c49a5bf7e6a00404a8a;hb=a2a2374cccb34420838746a6e17607d2bbef3fa8;hp=da84c371175bb970746997b43bea811c8297b131;hpb=5df414c25b1b710bea5e48e5183a28751b374659;p=rust-lightning diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index da84c371..77969ae9 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -391,20 +391,20 @@ impl Writeable for Route { write_ver_prefix!(writer, SERIALIZATION_VERSION, MIN_SERIALIZATION_VERSION); (self.paths.len() as u64).write(writer)?; let mut blinded_tails = Vec::new(); - for path in self.paths.iter() { + for (idx, path) in self.paths.iter().enumerate() { (path.hops.len() as u8).write(writer)?; - for (idx, hop) in path.hops.iter().enumerate() { + for hop in path.hops.iter() { hop.write(writer)?; - if let Some(blinded_tail) = &path.blinded_tail { - if blinded_tails.is_empty() { - blinded_tails = Vec::with_capacity(path.hops.len()); - for _ in 0..idx { - blinded_tails.push(None); - } - } - blinded_tails.push(Some(blinded_tail)); - } else if !blinded_tails.is_empty() { blinded_tails.push(None); } } + if let Some(blinded_tail) = &path.blinded_tail { + if blinded_tails.is_empty() { + blinded_tails = Vec::with_capacity(path.hops.len()); + for _ in 0..idx { + blinded_tails.push(None); + } + } + blinded_tails.push(Some(blinded_tail)); + } else if !blinded_tails.is_empty() { blinded_tails.push(None); } } write_tlv_fields!(writer, { // For compatibility with LDK versions prior to 0.0.117, we take the individual