public override byte[] ToBytes() { var versionBytes = BitConverter.GetBytes(Version); var servicesBytes = BitConverter.GetBytes(Services); var timeStampBytes = BitConverter.GetBytes(TimeStamp.Ticks); // We leave out the IPAddress TimeStamp in the Version Message. var addressToBytes = AddressTo.ToBytes().Skip(4).ToArray(); var addressFromBytes = AddressFrom.ToBytes().Skip(4).ToArray(); var nonceBytes = BitConverter.GetBytes(Nonce); var userAgentBytes = UserAgent.ToBytes(); var startHeightBytes = BitConverter.GetBytes(StartHeight); var relayBytes = BitConverter.GetBytes(Relay); return(versionBytes .Concat(servicesBytes) .Concat(timeStampBytes) .Concat(addressToBytes) .Concat(addressFromBytes) .Concat(nonceBytes) .Concat(userAgentBytes) .Concat(startHeightBytes) .Concat(relayBytes) .ToArray()); }
public override int GetHashCode() { int hash = 1; if (AddressTo.Length != 0) { hash ^= AddressTo.GetHashCode(); } if (Value != 0UL) { hash ^= Value.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }