Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created December 18, 2019 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/cf2f0209fdb8ef2338a0e799159f3caf to your computer and use it in GitHub Desktop.
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
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