Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Adding Proof of Work to blockchain

Blockchain.prototype.proofOfWork = function(prevBlockHash, currentBlockData) {
    let nonce = 0;
    let hash = this.hashBlock(prevBlockHash, currentBlockData, nonce);

    while (hash.substring(0,4) !== '0000') {
        nonce++;
        hash = this.hashBlock(prevBlockHash, currentBlockData, nonce);
    }

    return nonce;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Accessing Our CryptoCurrency blockchain through local server 
Javascript :: puppeteer create folder 
Javascript :: Sorting the Odd way! 
Javascript :: ngrx angular Cannot add property 0, object is not extensible 
Javascript :: node-schedule cancel job 
Javascript :: A Node Module For ReactJS 
Javascript :: $faker randomElements 
Javascript :: javascript how to random set rgb colors 
Javascript :: querySelectorAll select multiple element types 
Javascript :: Download A File With Link Using ExpressJS 
Javascript :: how to return data from function in javascript 
Javascript :: give call suggestions while clicking on a contact number in next js 
Javascript :: Toggle child element onclick of parent element 
Javascript :: jquery properties 
Javascript :: react mui pagination change text color site:stackoverflow.com 
Javascript :: onclick readmore and readless react js 
Javascript :: javascript protect object with proxy 
Javascript :: sinha express crud template 
Javascript :: slicer 
Javascript :: iconbuttons onclick redirect to another page on react 
Javascript :: Solution-4-C--solution options for reverse bits algorithm js 
Javascript :: convert text to number 
Javascript :: editor convert jquery code to javascript 
Javascript :: table to excel javascript 
Javascript :: math.ceil node js 
Javascript :: how to set width 100 react native 
Javascript :: how to pause settimeout in javascript 
Javascript :: insertmany 
Javascript :: JavaScript Change the Value of Variables 
Javascript :: Export Multiple Objects 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =