Lets Build a Blockchain
Let's build a blockchain
Our BlockChain
Proof of Work
proofOfWork(difficulty) {
const my = this;
my.canceled = false;
return new Promise((resolve, reject)=>{
while (hash.substring(0, difficulty) !== Array(difficulty + 1).join("0")) {
if (my.canceled) reject("Proof of Work aborted");
my.nonce++;
my.hash = this.computeHash();
}
resolve(my.hash);
});
}