From 3edd9e4bee49af6ab72c995f3d900266862ea2c9 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Thu, 27 Oct 2016 15:25:54 +0200 Subject: [PATCH] Fixed GetNodeData output (#2892) --- sync/src/chain.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 764eccdac..d18adb6ea 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -1428,16 +1428,18 @@ impl ChainSync { } count = min(count, MAX_NODE_DATA_TO_SEND); let mut added = 0usize; - let mut data = Bytes::new(); + let mut data = Vec::new(); for i in 0..count { - if let Some(mut hdr) = io.chain().state_data(&try!(r.val_at::(i))) { - data.append(&mut hdr); + if let Some(hdr) = io.chain().state_data(&try!(r.val_at::(i))) { + data.push(hdr); added += 1; } } trace!(target: "sync", "{} -> GetNodeData: return {} entries", peer_id, added); let mut rlp = RlpStream::new_list(added); - rlp.append_raw(&data, added); + for d in data.into_iter() { + rlp.append(&d); + } Ok(Some((NODE_DATA_PACKET, rlp))) } @@ -2026,7 +2028,9 @@ mod tests { assert!(rlp_result.is_some()); // the length of one rlp-encoded hashe - assert_eq!(34, rlp_result.unwrap().1.out().len()); + let rlp = rlp_result.unwrap().1.out(); + let rlp = Rlp::new(&rlp); + assert_eq!(1, rlp.item_count()); io.sender = Some(2usize);