X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fpeer_handler.rs;h=12cf937bc0f07785fbb58d93db58355dbbf0dce9;hb=6f06858304c49742ad80216dd693e65f5c18ecbe;hp=9cbd02121e9e55231a58b7b4b3c935a9b0b07a23;hpb=83c9eb4b9e0a461fee980fc6cc01d1b72597b2fa;p=rust-lightning diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 9cbd0212..12cf937b 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -445,7 +445,7 @@ impl PeerManager where /// on this file descriptor has resume_read set (preventing DoS issues in the send buffer). /// /// Panics if the descriptor was not previously registered in a new_*_connection event. - pub fn read_event(&self, peer_descriptor: &mut Descriptor, data: Vec) -> Result { + pub fn read_event(&self, peer_descriptor: &mut Descriptor, data: &[u8]) -> Result { match self.do_read_event(peer_descriptor, data) { Ok(res) => Ok(res), Err(e) => { @@ -455,7 +455,7 @@ impl PeerManager where } } - fn do_read_event(&self, peer_descriptor: &mut Descriptor, data: Vec) -> Result { + fn do_read_event(&self, peer_descriptor: &mut Descriptor, data: &[u8]) -> Result { let pause_read = { let mut peers_lock = self.peers.lock().unwrap(); let peers = &mut *peers_lock; @@ -1228,9 +1228,9 @@ mod tests { let mut fd_b = FileDescriptor { fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())) }; let initial_data = peer_b.new_outbound_connection(a_id, fd_b.clone()).unwrap(); peer_a.new_inbound_connection(fd_a.clone()).unwrap(); - assert_eq!(peer_a.read_event(&mut fd_a, initial_data).unwrap(), false); - assert_eq!(peer_b.read_event(&mut fd_b, fd_a.outbound_data.lock().unwrap().split_off(0)).unwrap(), false); - assert_eq!(peer_a.read_event(&mut fd_a, fd_b.outbound_data.lock().unwrap().split_off(0)).unwrap(), false); + assert_eq!(peer_a.read_event(&mut fd_a, &initial_data).unwrap(), false); + assert_eq!(peer_b.read_event(&mut fd_b, &fd_a.outbound_data.lock().unwrap().split_off(0)).unwrap(), false); + assert_eq!(peer_a.read_event(&mut fd_a, &fd_b.outbound_data.lock().unwrap().split_off(0)).unwrap(), false); } #[test]