Show / Hide Table of Contents

Class Hashcash

This contains a set of functions that implements Hashcash, a proof-of-work system.

Inheritance
Object
Hashcash
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet
Assembly: Libplanet.dll
Syntax
public static class Hashcash

Methods

| Improve this Doc View Source

Answer(Hashcash.Stamp, HashAlgorithmType, Int64, CancellationToken)

Finds a Nonce that satisfies the given difficulty. This process is so-called “mining”.

Declaration
public static (Nonce Nonce, ImmutableArray<byte> Digest) Answer(Hashcash.Stamp stamp, HashAlgorithmType hashAlgorithmType, long difficulty, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
Hashcash.Stamp stamp

A callback to get a “stamp” which is a Byte array determined from a given Nonce value.

HashAlgorithmType hashAlgorithmType

The hash algorithm to use.

Int64 difficulty

A number to calculate the target number for which the returned answer should be less than.

CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
(T1, T2)<Nonce, ImmutableArray<Byte>>

A pair of Nonce value which satisfies the given difficulty, and the succeeded hash digest.

Exceptions
Type Condition
OperationCanceledException

Thrown when the specified cancellationToken received a cancellation request.

See Also
Hashcash.Stamp
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium