ProofOfWork class
Proof-of-Work helper built for deterministic simulation and testing.
Advanced features:
- accepts a pluggable
BigHashfunction for arbitrary hash spaces minesupports an optionalshouldStopcallback for cancellationverifyhelper to validate a candidate against a target- utilities to compute numeric
targetfrom compact difficulty bits
Constructors
- ProofOfWork({required BigHash hashFn, int? seed})
Properties
Methods
-
mine(
String data, BigInt target, {int maxAttempts = 1000000, bool shouldStop()?}) → MineResult -
Mine
datauntilhash <= targetormaxAttemptsreached. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
verify(
String data, int nonce, BigInt target) → bool -
Verify that a
noncefordatameets thetarget.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
targetFromCompact(
int compact) → BigInt - Compact bits -> target (toy implementation similar to Bitcoin's compact format).