Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: jubalix on August 20, 2014, 07:09:30 AM



Title: How blocks are linked together
Post by: jubalix on August 20, 2014, 07:09:30 AM
Once a block is found, and accepted, what/how is it links it to the previous block...


*I think it is the commonly accepted time stamp and that every one accepts the longest chain, and then is it a hash of very thing before + last block to give new hash that must be then used for the next one....*

I am being a bit lazy by not reading the white paper and code base


if some on could be so kind as to explain to me all the hooks used to link blocks together I would appreciate this.




Title: Re: How blocks are linked together
Post by: azeteki on August 20, 2014, 12:45:52 PM
It's linked to the previous block before the PoW is 'solved', during construction of the unsolved block.

The data hashed for the PoW puzzle includes 'hashPrevBlock'.


Title: Re: How blocks are linked together
Post by: DannyHamilton on August 20, 2014, 01:33:57 PM
Once a block is found, and accepted, what/how is it links it to the previous block...

It is not.  It is linked to the previous block BEFORE it is "found and accepted".

*I think it is the commonly accepted time stamp

No.  Timestamps are not used to link blocks.  Timestamps are not even always in order.  The timestamps in a block are not a reliable indication of the exact time that a block is solved, and can be off by more than an hour.

and that every one accepts the longest chain, and then is it a has of very thing before + last block to give new hash that must be then used for the next one....*

I'm having a difficult time making sense of what you are saying there.  As has already been pointed out, before you start trying to "solve" a block, you first build the block header.  The block header includes the hash of the previous block that you are "linking to".  This sets an order for the blocks, each block referencing its previous block all the way back to the origin block.

I am being a bit lazy

Clearly.


Title: Re: How blocks are linked together
Post by: Dabs on August 20, 2014, 04:32:32 PM
Quote
Name:    jubalix
Posts:    2830
Activity:    560
Position:    Hero Member
Date Registered:    2013-02-27, 05:39:17

How can you not know about bitcoin? I don't expect you to know exactly how it all works, but the mechanics of the blockchain should have made sense to you a long time ago.


Title: Re: How blocks are linked together
Post by: jubalix on September 21, 2014, 08:06:27 AM
Quote
Name:    jubalix
Posts:    2830
Activity:    560
Position:    Hero Member
Date Registered:    2013-02-27, 05:39:17

How can you not know about bitcoin? I don't expect you to know exactly how it all works, but the mechanics of the blockchain should have made sense to you a long time ago.

yeah i have not gone over the code base, nor hung round in the dev part much, I did figure it out though, its a hash of the last block combined with the next block if you read above.

I thought however there maybe more hooks in the code base, as redundancy or something, which is why I said *all* the hooks


Title: Re: How blocks are linked together
Post by: DannyHamilton on September 21, 2014, 02:14:11 PM
- snip -
I thought however there maybe more hooks in the code base, as redundancy or something

Nope.  That's all there is.