@@ -9,8 +9,8 @@ use lightning::ln::msgs::{DecodeError, ErrorAction, LightningError, SocketAddres
9
9
use lightning:: routing:: gossip:: { NetworkGraph , NodeAlias , NodeId } ;
10
10
use lightning:: util:: logger:: Logger ;
11
11
use lightning:: { log_debug, log_warn, log_trace, log_given_level, log_gossip} ;
12
- use lightning:: util:: ser:: { BigSize , Readable } ;
13
- use lightning:: io ;
12
+ use lightning:: util:: ser:: { BigSize , FixedLengthReader , Readable } ;
13
+ use lightning:: { io , io :: Read } ;
14
14
15
15
use crate :: { GraphSyncError , RapidGossipSync } ;
16
16
@@ -141,8 +141,9 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
141
141
let mut node_addresses: Vec < SocketAddress > = Vec :: new ( ) ;
142
142
for _ in 0 ..address_count {
143
143
let current_byte_count: u8 = Readable :: read ( read_cursor) ?;
144
- let mut address_bytes = vec ! [ 0u8 ; current_byte_count as usize ] ;
145
- read_cursor. read_exact ( & mut address_bytes) . unwrap ( ) ;
144
+ let mut address_reader = FixedLengthReader :: new ( & mut read_cursor, current_byte_count as u64 ) ;
145
+ let mut address_bytes = Vec :: new ( ) ;
146
+ address_reader. read_to_end ( & mut address_bytes) . unwrap ( ) ;
146
147
147
148
let mut address_cursor = io:: Cursor :: new ( & address_bytes) ;
148
149
if let Ok ( current_address) = Readable :: read ( & mut address_cursor) {
0 commit comments