Add version and TLV suffix for more user-facing "major" structs
[rust-lightning] / lightning / src / routing / router.rs
index ba964d734c670e4cfbbc4d12eca1ea9e71f37491..489b900605384a52423547964d89db3113883d0b 100644 (file)
@@ -95,23 +95,30 @@ pub struct Route {
        pub paths: Vec<Vec<RouteHop>>,
 }
 
+const SERIALIZATION_VERSION: u8 = 1;
+const MIN_SERIALIZATION_VERSION: u8 = 1;
+
 impl Writeable for Route {
        fn write<W: ::util::ser::Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
+               write_ver_prefix!(writer, SERIALIZATION_VERSION, MIN_SERIALIZATION_VERSION);
                (self.paths.len() as u64).write(writer)?;
                for hops in self.paths.iter() {
                        hops.write(writer)?;
                }
+               write_tlv_fields!(writer, {}, {});
                Ok(())
        }
 }
 
 impl Readable for Route {
        fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Route, DecodeError> {
+               let _ver = read_ver_prefix!(reader, SERIALIZATION_VERSION);
                let path_count: u64 = Readable::read(reader)?;
                let mut paths = Vec::with_capacity(cmp::min(path_count, 128) as usize);
                for _ in 0..path_count {
                        paths.push(Readable::read(reader)?);
                }
+               read_tlv_fields!(reader, {}, {});
                Ok(Route { paths })
        }
 }