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

Commit

Permalink
Printing warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Sep 26, 2016
1 parent cc7456d commit 55b804a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rpc/src/v1/types/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ impl Visitor for BytesVisitor {

fn visit_str<E>(&mut self, value: &str) -> Result<Self::Value, E> where E: Error {
if value.is_empty() {
warn!(
target: "deprecated",
"Deserializing empty string as empty bytes. This is a non-standard behaviour that will be removed in future versions. Please update your code to send `0x` instead!"
);
Ok(Bytes::new(Vec::new()))
} else if value.len() >= 2 && &value[0..2] == "0x" && value.len() & 1 == 0 {
Ok(Bytes::new(FromHex::from_hex(&value[2..]).unwrap_or_else(|_| vec![])))
Expand Down

0 comments on commit 55b804a

Please sign in to comment.