protected override GetAccountRangeMessage Deserialize(RlpStream rlpStream) { GetAccountRangeMessage message = new (); rlpStream.ReadSequenceLength(); message.RequestId = rlpStream.DecodeLong(); message.AccountRange = new(rlpStream.DecodeKeccak(), rlpStream.DecodeKeccak(), rlpStream.DecodeKeccak()); message.ResponseBytes = rlpStream.DecodeLong(); return(message); }
public PingMessage Deserialize(byte[] msg) { (PingMessage Message, byte[] Mdc, byte[] Data)results = PrepareForDeserialization <PingMessage>(msg); RlpStream rlp = results.Data.AsRlpStream(); rlp.ReadSequenceLength(); int version = rlp.DecodeInt(); rlp.ReadSequenceLength(); byte[] sourceAddress = rlp.DecodeByteArray(); IPEndPoint source = GetAddress(sourceAddress, rlp.DecodeInt()); rlp.DecodeInt(); // UDP port rlp.ReadSequenceLength(); byte[] destinationAddress = rlp.DecodeByteArray(); IPEndPoint destination = GetAddress(destinationAddress, rlp.DecodeInt()); rlp.DecodeInt(); // UDP port long expireTime = rlp.DecodeLong(); PingMessage message = results.Message; message.SourceAddress = source; message.DestinationAddress = destination; message.Mdc = results.Mdc; message.Version = version; message.ExpirationTime = expireTime; return(message); }
public PingMsg Deserialize(byte[] msgBytes) { (PublicKey FarPublicKey, byte[] Mdc, byte[] Data)results = PrepareForDeserialization(msgBytes); RlpStream rlp = results.Data.AsRlpStream(); rlp.ReadSequenceLength(); int version = rlp.DecodeInt(); rlp.ReadSequenceLength(); ReadOnlySpan <byte> sourceAddress = rlp.DecodeByteArraySpan(); // TODO: please note that we decode only one field for port and if the UDP is different from TCP then // our discovery messages will not be routed correctly (the fix will not be part of this commit) rlp.DecodeInt(); // UDP port int tcpPort = rlp.DecodeInt(); // we assume here that UDP and TCP port are same IPEndPoint source = GetAddress(sourceAddress, tcpPort); rlp.ReadSequenceLength(); ReadOnlySpan <byte> destinationAddress = rlp.DecodeByteArraySpan(); IPEndPoint destination = GetAddress(destinationAddress, rlp.DecodeInt()); rlp.DecodeInt(); // UDP port long expireTime = rlp.DecodeLong(); PingMsg msg = new(results.FarPublicKey, expireTime, source, destination, results.Mdc); msg.Version = version; if (version == 4) { if (!rlp.HasBeenRead) { long enrSequence = rlp.DecodeLong(); msg.EnrSequence = enrSequence; } } else { // what do we do when receive version 5? } return(msg); }
public EnrRequestMsg Deserialize(byte[] msgBytes) { (PublicKey FarPublicKey, byte[] Mdc, byte[] Data)results = PrepareForDeserialization(msgBytes); RlpStream rlpStream = results.Data.AsRlpStream(); rlpStream.ReadSequenceLength(); long expirationTime = rlpStream.DecodeLong(); EnrRequestMsg msg = new (results.FarPublicKey, expirationTime); return(msg); }
public PingMessage Deserialize(byte[] msg) { (PingMessage Message, byte[] Mdc, byte[] Data)results = PrepareForDeserialization <PingMessage>(msg); RlpStream rlp = results.Data.AsRlpStream(); rlp.ReadSequenceLength(); int version = rlp.DecodeInt(); rlp.ReadSequenceLength(); ReadOnlySpan <byte> sourceAddress = rlp.DecodeByteArraySpan(); // TODO: please note that we decode only one field for port and if the UDP is different from TCP then // our discovery messages will not be routed correctly (the fix will not be part of this commit) rlp.DecodeInt(); // UDP port int tcpPort = rlp.DecodeInt(); // we assume here that UDP and TCP port are same IPEndPoint source = GetAddress(sourceAddress, tcpPort); rlp.ReadSequenceLength(); ReadOnlySpan <byte> destinationAddress = rlp.DecodeByteArraySpan(); IPEndPoint destination = GetAddress(destinationAddress, rlp.DecodeInt()); rlp.DecodeInt(); // UDP port long expireTime = rlp.DecodeLong(); PingMessage message = results.Message; message.SourceAddress = source; message.DestinationAddress = destination; message.Mdc = results.Mdc; message.Version = version; message.ExpirationTime = expireTime; return(message); }