parity-common
parity-common copied to clipboard
rlp: handling extra data
Unsure if this a bug or an api shortcoming.
When decoding bytes that have extra data, I would expect one of:
- an error on decoding
- a way to know the number of bytes that were readed, to externally deal with trailing data
example:
let input = vec![123, 32, 4, 156, 231, 200];
let mut stream = rlp::RlpStream::new();
input.rlp_append(&mut stream);
let bytes = stream.out().freeze();
let mut extra_data = bytes.to_vec();
extra_data.push(23);
extra_data.push(40);
rlp::decode::<Vec<u8>>(&extra_data).expect_err("extra data should not be ignored");