Skip to content

Commit 2612569

Browse files
committed
f use bits 6 and 7 as joint descriptions of additional data length
1 parent 8ddc51e commit 2612569

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

lightning-rapid-gossip-sync/src/processing.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,25 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
183183
node_modifications.insert(current_pubkey, synthetic_node_announcement);
184184
}
185185

186-
let has_additional_data = additional_data_marker > 0;
187186
if additional_data_marker > 0 {
188-
// 1 => u8, 2 => u16, 3 => u32
189-
let _length_prefix_bytes = 1u8 << (additional_data_marker - 1);
190-
// let _length_prefix = match length_prefix_bytes {
191-
//
192-
// };
187+
let additional_byte_count: u64 = match additional_data_marker {
188+
1 => {
189+
u8::read(read_cursor)? as u64
190+
}
191+
2 => {
192+
u16::read(read_cursor)? as u64
193+
}
194+
3 => {
195+
u32::read(read_cursor)? as u64
196+
}
197+
_ => {
198+
return Err(DecodeError::BadLengthDescriptor.into());
199+
}
200+
};
201+
202+
let mut additional_data_reader = FixedLengthReader::new(&mut read_cursor, additional_byte_count);
203+
let mut additional_data = Vec::new();
204+
additional_data_reader.read_to_end(&mut additional_data)?;
193205
}
194206

195207
if has_additional_data {

0 commit comments

Comments
 (0)