Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

fixed encoding 0u8 #992

Merged
merged 2 commits into from
Apr 24, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions util/src/rlp/rlpstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,18 @@ struct EncodableU8 (u8);

impl ByteEncodable for EncodableU8 {
fn to_bytes<V: VecLike<u8>>(&self, out: &mut V) {
out.vec_push(self.0)
if self.0 != 0 {
out.vec_push(self.0)
}
}

fn bytes_len(&self) -> usize { 1 }
fn bytes_len(&self) -> usize {
if self.0 == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use match self.0 { 0 => 0, _ => 1 }

0
} else {
1
}
}
}

impl RlpEncodable for u8 {
Expand Down