Does timestamp also change with nonce to calculate block hash in blockchain How hash is calculated

0 votes

Do we need to update the date timestamp on every hash calculation update? How it's implemented in the most popular cryptocurrencies?

function isValidHashDifficulty() { //validate calculated hash to fit requirements } function calculateHash(nextIndex, previousHash, timestamp, data, nonce) { //calculate hash } let nonce = 0; let nextIndex, previousHash, data; let timestamp = new Date().getTime(); // do we use this timestamp? while (!isValidHashDifficulty(nextHash)) { nonce = nonce + 1; timestamp = new Date().getTime(); //or do we get new date on every calculation attempt? nextHash = calculateHash(nextIndex, previousHash, timestamp, data, nonce); }

Apr 6, 2022 in Blockchain by Aditya
• 7,680 points
2,327 views

1 answer to this question.