Show / Hide Table of Contents

Struct BlockHash

A value type to represent SHA-256 digest of Block<T> data.

Implements
ISerializable
IEquatable<BlockHash>
Namespace: Libplanet.Blocks
Assembly: Libplanet.dll
Syntax
public readonly struct BlockHash : ISerializable, IEquatable<BlockHash>

Constructors

| Improve this Doc View Source

BlockHash(ImmutableArray<Byte>)

Converts an immutable array into a BlockHash.

Declaration
public BlockHash(ImmutableArray<byte> blockHash)
Parameters
Type Name Description
ImmutableArray<Byte> blockHash

An immutable array that encodes a SHA-256 digest of a Block<T>.

| Improve this Doc View Source

BlockHash(Byte[])

Converts a array into a BlockHash.

Declaration
public BlockHash(byte[] blockHash)
Parameters
Type Name Description
Byte[] blockHash

A array that encodes a BlockHash.

Fields

| Improve this Doc View Source

Size

The size of bytes that each BlockHash consists of.

Declaration
public const int Size = null
Field Value
Type Description
Int32

Properties

| Improve this Doc View Source

ByteArray

A bare immutable array of the block hash.

Declaration
public readonly ImmutableArray<byte> ByteArray { get; }
Property Value
Type Description
ImmutableArray<Byte>
Remarks

It is immutable. For a mutable array, use ToByteArray() method instead.

See Also
ToByteArray()

Methods

| Improve this Doc View Source

DeriveFrom(IReadOnlyList<Byte>)

Computes a SHA-256 digest from the given blockBytes.

Declaration
public static BlockHash DeriveFrom(IReadOnlyList<byte> blockBytes)
Parameters
Type Name Description
IReadOnlyList<Byte> blockBytes

The bytes serializing a block to compute its hash.

Returns
Type Description
BlockHash

The SHA-256 hash digest derived from blockBytes.

| Improve this Doc View Source

Equals(BlockHash)

Declaration
public readonly bool Equals(BlockHash other)
Parameters
Type Name Description
BlockHash other
Returns
Type Description
Boolean
| Improve this Doc View Source

Equals(Nullable<Object>)

Declaration
public override readonly bool Equals(object? obj)
Parameters
Type Name Description
Nullable<Object> obj
Returns
Type Description
Boolean
| Improve this Doc View Source

FromHashDigest(HashDigest<SHA256>)

Converts a given HashDigest<T> into a BlockHash value.

Declaration
public static BlockHash FromHashDigest(HashDigest<SHA256> hashDigest)
Parameters
Type Name Description
HashDigest<SHA256> hashDigest

A SHA-256 digest.

Returns
Type Description
BlockHash

A block hash corresponding to the hashDigest.

| Improve this Doc View Source

FromString(String)

Converts a given hexadecimal representation of a block hash into a BlockHash value.

This is an inverse function of ToString() method.

Declaration
public static BlockHash FromString(string hex)
Parameters
Type Name Description
String hex

A hexadecimal representation of a BlockHash.

Returns
Type Description
BlockHash

A corresponding BlockHash value.

See Also
ToString()
| Improve this Doc View Source

GetHashCode()

Declaration
public override readonly int GetHashCode()
Returns
Type Description
Int32
| Improve this Doc View Source

GetObjectData(SerializationInfo, StreamingContext)

Declaration
public readonly void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
SerializationInfo info
StreamingContext context
| Improve this Doc View Source

ToByteArray()

Gets a bare mutable array of the block hash.

Declaration
public readonly byte[] ToByteArray()
Returns
Type Description
Byte[]

A new mutable array of the block hash. Since a returned array is created every time the method is called, any mutations on that array does not affect to the block hash object.

See Also
ByteArray
| Improve this Doc View Source

ToString()

Declaration
public override readonly string ToString()
Returns
Type Description
String

Implements

ISerializable
IEquatable<>

See Also

Hash
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium