diff --git a/src/network/connection.rs b/src/network/connection.rs index 65460f1bd..9fbd4df76 100644 --- a/src/network/connection.rs +++ b/src/network/connection.rs @@ -253,7 +253,7 @@ impl EncryptedConnection { let length = ((((hdec[0] as u32) << 8) + (hdec[1] as u32)) << 8) + (hdec[2] as u32); let header_rlp = UntrustedRlp::new(&hdec[3..6]); - let protocol_id = try!(u16::decode_untrusted(&try!(header_rlp.at(0)))); + let protocol_id = try!(header_rlp.val_at::(0)); self.payload_len = length; self.protocol_id = protocol_id; diff --git a/src/network/session.rs b/src/network/session.rs index 698f8f6ac..a34f6ff1a 100644 --- a/src/network/session.rs +++ b/src/network/session.rs @@ -38,10 +38,12 @@ pub struct PeerCapabilityInfo { } impl Decodable for PeerCapabilityInfo { - fn decode_untrusted(rlp: &UntrustedRlp) -> Result { + fn decode(decoder: &D) -> Result where D: Decoder { + let c = try!(decoder.as_list()); + let v: u32 = try!(Decodable::decode(&c[1])); Ok(PeerCapabilityInfo { - protocol: try!(String::decode_untrusted(&try!(rlp.at(0)))), - version: try!(u32::decode_untrusted(&try!(rlp.at(1)))) as u8, + protocol: try!(Decodable::decode(&c[0])), + version: v as u8, }) } } @@ -170,10 +172,10 @@ impl Session { } fn read_hello(&mut self, rlp: &UntrustedRlp, host: &HostInfo) -> Result<(), Error> { - let protocol = try!(u32::decode_untrusted(&try!(rlp.at(0)))); - let client_version = try!(String::decode_untrusted(&try!(rlp.at(1)))); - let peer_caps: Vec = try!(Decodable::decode_untrusted(&try!(rlp.at(2)))); - let id = try!(NodeId::decode_untrusted(&try!(rlp.at(4)))); + let protocol = try!(rlp.val_at::(0)); + let client_version = try!(rlp.val_at::(1)); + let peer_caps = try!(rlp.val_at::>(2)); + let id = try!(rlp.val_at::(4)); // Intersect with host capabilities // Leave only highset mutually supported capability version