Пример #1
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (BlockNum != 0UL)
        {
            hash ^= BlockNum.GetHashCode();
        }
        if (PreviousBlockId.Length != 0)
        {
            hash ^= PreviousBlockId.GetHashCode();
        }
        if (SignerPublicKey.Length != 0)
        {
            hash ^= SignerPublicKey.GetHashCode();
        }
        hash ^= batchIds_.GetHashCode();
        if (Consensus.Length != 0)
        {
            hash ^= Consensus.GetHashCode();
        }
        if (StateRootHash.Length != 0)
        {
            hash ^= StateRootHash.GetHashCode();
        }
        if (_unknownFields != null)
        {
            hash ^= _unknownFields.GetHashCode();
        }
        return(hash);
    }
Пример #2
0
        public byte[] GetBytes(bool skipSignature = false)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(PreviousBlockId.ToByteArray());
                    writer.Write(Height);
                    writer.Write(Timestamp);

                    writer.Write(PayloadLength);
                    writer.Write(PayloadHash.FromHex());
                    writer.Write(Delegate.FromHex());
                    writer.Write(PointId.ToByteArray());
                    writer.Write(PointHeight);
                    writer.Write(BlockCount);
                    writer.Write(Height);

                    if (!skipSignature && !string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }
                }
                return(stream.ToArray());
            }
        }