Jazerix
Jazerix

Reputation: 4801

If the blocks can only be traversed backwards, how do we know which one is the newest?

Our blockchain consists of a range of blocks that are chained together with a linked list, going only backward, where each block header has a prevHash (bitcoin) or parentHash (ethereum).

Here's my question: If I can't go forward, how do I know I'm on the latest block?

Do I ask other peers in the network what block they are on?

And, theoretically, if I'm the only one on the network, what happens then?

Upvotes: 1

Views: 99

Answers (1)

Petr Hejda
Petr Hejda

Reputation: 43521

If I can't go forward, how do I know I'm on the latest block?

Each miner, after they created a block, broadcasts the new block (including its number) to the network.

So each node (both miners and non-miners) gets the latest block from this broadcasted message.

Plus, you can also ask other peers directly about their current block to validate if you're on the current block as well.

Note: Sometimes multiple miners create and broadcast a valid block with the same number. Only one of them is accepted by the network (usually the one with the lowest timestamp) and the others are discarded as "uncle blocks".

And, theoretically, if I'm the only one on the network, what happens then?

Then you're the only miner as well, so you also have the last block number from the block that you mined.

Upvotes: 1

Related Questions