Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Fuzzy on June 07, 2012, 11:46:47 AM



Title: How does bitcoin know what time it is?
Post by: Fuzzy on June 07, 2012, 11:46:47 AM
Since the bitcoin network requires a point of reference to see how far apart the ends of a 2016 block cycle are, what source does it use to tell time? At the end of whatever convoluted process it uses, there is a clock/timer somewhere that is used for reference.

I'm asking because that would be a potential weakness in the bitcoin protocol.


Title: Re: How does bitcoin know what time it is?
Post by: drakahn on June 07, 2012, 11:56:09 AM
Quote
A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours.

"Network-adjusted time" is the median of the timestamps returned by all nodes connected to you.
Whenever a node connects to another node, it gets a UTC timestamp from it, and stores its offset from node-local UTC. The network-adjusted time is then the node-local UTC plus the median offset from all connected nodes.

https://en.bitcoin.it/wiki/Block_timestamp


Title: Re: How does bitcoin know what time it is?
Post by: Fuzzy on June 07, 2012, 12:01:28 PM
Thanks! Might as well quote it here:

Quote
Each block contains a Unix time timestamp. In addition to serving as a source of variation for the block hash, there are also validity checks, that make it more difficult for an adversary to manipulate the block chain.

A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours. "Network-adjusted time" is the median of the timestamps returned by all nodes connected to you.

Whenever a node connects to another node, it gets a UTC timestamp from it, and stores its offset from node-local UTC. The network-adjusted time is then the node-local UTC plus the median offset from all connected nodes. Network time is never adjusted more than 70 minutes from local system time, however.

Bitcoin uses an unsigned integer for the timestamp, so the year 2038 problem is delayed for another 68 years.


That Satoshi is one smart cookie  :)


Title: Re: How does bitcoin know what time it is?
Post by: Raoul Duke on June 07, 2012, 12:35:29 PM
Quote
Each block contains a Unix time timestamp. In addition to serving as a source of variation for the block hash, there are also validity checks, that make it more difficult for an adversary to manipulate the block chain.

A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours. "Network-adjusted time" is the median of the timestamps returned by all nodes connected to you.

Whenever a node connects to another node, it gets a UTC timestamp from it, and stores its offset from node-local UTC. The network-adjusted time is then the node-local UTC plus the median offset from all connected nodes. Network time is never adjusted more than 70 minutes from local system time, however.

Bitcoin uses an unsigned integer for the timestamp, so the year 2038 problem is delayed for another 68 years.

They better start working on it lol


Title: Re: How does bitcoin know what time it is?
Post by: Hexadecibel on June 09, 2012, 04:50:03 AM
I have grand plans of being alive when the last block in mined, and buying a portal gun with 1BTC


Title: Re: How does bitcoin know what time it is?
Post by: Fuzzy on June 12, 2012, 06:16:40 AM
I have grand plans of being alive when the last block in mined, and buying a portal gun with 1BTC

You plan on spending 1/21,000,000th of the worlds only trusted currency on a gadget? How immature.
I'm gonna use my Bitcoin to buy a small cottage on mars.