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 in Blockchain by Aditya
• 7,660 points
178 views

1 answer to this question.

0 votes

I was unable to locate the exact place in the Bitcoin codebase, but I am now certain that the timestamp does not change each time, since it would be a pretty meaningless operation that would just slow down the search for the solution to the mining puzzle. The timestamps of blocks in the blockchain are not required to be in the strictly increasing order. This is due to the fact that the network is distributed throughout the world, and there is no designated time zone that is to be used for timestamps.

Basically, a timestamp just needs to be "not too old", or if you want it more precisely: "a timestamp is accepted as valid if it is greater than the median timestamp of the previous 11 blocks, and less than the network-adjusted time + 2 hours"

answered Apr 12 by Soham
• 9,670 points

Related Questions In Blockchain

0 votes
1 answer

In a Blockchain, how difficult is it to modify the third to last block?

Technically, it's not difficult at all, all ...READ MORE

answered Apr 20, 2018 in Blockchain by Christine
• 15,790 points
535 views
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,440 points
732 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,110 views
0 votes
1 answer
0 votes
1 answer

(bitcoin) Calculate hash from getwork function - how to do it?

This is correct as there is a ...READ MORE

answered Feb 28 in Blockchain by Soham
• 9,670 points
187 views
0 votes
1 answer

How can merkle trees help validate the content of a block in a blockchain

As long as they are centralized entities ...READ MORE

answered Feb 28 in Blockchain by Soham
• 9,670 points
247 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP