public override VersionMessage Deserialize(ref SequenceReader <byte> reader, int protocolVersion, BitcoinPeerContext peerContext) { var message = new VersionMessage { Version = reader.ReadInt(), Services = reader.ReadULong(), Timestamp = DateTimeOffset.FromUnixTimeSeconds(reader.ReadLong()), ReceiverAddress = reader.ReadWithSerializer(protocolVersion, _networkAddressNoTimeSerializer) }; if (message.Version < KnownVersion.V106) { return(message); } message.SenderAddress = reader.ReadWithSerializer(protocolVersion, _networkAddressNoTimeSerializer); message.Nonce = reader.ReadULong(); message.UserAgent = reader.ReadVarString(); message.StartHeight = reader.ReadInt(); if (message.Version < KnownVersion.V70001) { return(message); } message.Relay = reader.ReadBool(); return(message); }
public override VersionMessage Deserialize(ReadOnlySpan <byte> data) { var reader = new SequenceReader <byte>(new ReadOnlySequence <byte>(data.ToArray())); var message = new VersionMessage(); message.Version = reader.ReadInt(); message.Services = reader.ReadULong(); message.Timestamp = DateTimeOffset.FromUnixTimeSeconds(reader.ReadLong()); message.ReceiverAddress = reader.ReadNetworkAddress(); // from here down, if version >= 106 message.SenderAddress = reader.ReadNetworkAddress(); message.Nonce = reader.ReadULong(); message.UserAgent = reader.ReadVarString(); message.StartHeight = reader.ReadInt(); // from here down, if version >= 70001 message.Relay = reader.ReadBool(); return(message); }
public override SendCmpctMessage Deserialize(ref SequenceReader <byte> reader, int protocolVersion, BitcoinPeerContext peerContext) { return(new SendCmpctMessage { AnnounceUsingCompactBlock = reader.ReadBool(), Version = reader.ReadULong() }); }