resolve method
Implementation
Future<ProofOfWork> resolve(Function(double) onProgress) async {
final prefixHash = await _sha256(prefix);
double probabilityOfNotSuccessOnEachNonce = difficulty / _maxUint128;
double progressAccumulator = 1.0;
int nonce = 0;
BigInt result = BigInt.zero;
while (result < difficulty) {
nonce += 1;
result = await _score(prefixHash, nonce);
progressAccumulator *= probabilityOfNotSuccessOnEachNonce;
onProgress(1 - progressAccumulator);
}
return ProofOfWork(
nonce: nonce.toString(),
);
}