Created
December 18, 2019 13:33
-
-
Save ssaurel/cf2f0209fdb8ef2338a0e799159f3caf to your computer and use it in GitHub Desktop.
MineBlock function on the Blockchain in JS made on the SSaurel's Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Block.prototype.mineBlock = function(difficulty) { | |
this.nonce = 0; | |
var zeros = "0".repeat(difficulty); | |
while (this.hash.substring(0, difficulty) != zeros) { | |
this.nonce++; | |
this.hash = calculateHash(this); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment