If a bitcoin client goes offline or misses a new block, what is the process of finding the current, main blockchain? And how does bitcoin ensure that updates to the blockchain will be propogated to each device connected to the network (i.e. to make sure connected nodes never have a missed block in the ledger?) Does it somehow recursively backtrack from the next broadcasted block's reference to the previous block? And then how does it ensure that the current chain broadcasted is an addition to the main chain, rather than some fork? For example, if the client connects to the network and receives a block of given height, how does it both know that it has the most work of any chain, and that the local copy contains all blocks in the chain?
-
have a look here: transifex.com/bitcoinbook/mastering-bitcoin/languages Andreas book "Mastering Bitcoin" has already been translated into many languages, and serves as a very good start into the matter. There is also an online (english) version of the book. The answer(s) to your many questions would bee too much... This forum is intended to raise simple questions, one by one ...– pebwindkraftJul 14, 2017 at 8:03
-
@pebwindkraft thanks for the resource! I'm really wondering just the general process of how clients get new blocks after downtime. Everything else is surrounding that concept. I couldn't really find anything else online that answers how the client gets changes to the main block chain.– rb612Jul 14, 2017 at 21:03
1 Answer
Peers of the node will tell the node the height of their longest blockchain, and if this is greater than what the node currently has stored, it will request the missing blocks from that node (to validate and store them). Also, if a node is on the network and receives a new block, it will look at the hash of its parent and decide if it has the parent already or not. If it doesn't have the parent, it will ask its peers for it. That way it will eventually download all the blocks it is missing and be up to date again
The node will keep track of how long each fork of the blockchain is, and will use the longest one it finds which it considers valid. If a long fork appears which the node thinks is not valid, it will show a warning that either the node is out of date or the peers are.
-
Great explanation! Thanks! Could you explain more by your last sentence?– rb612Jul 15, 2017 at 3:07
-
If a chain looks invalid to a node, but its pretty long, it'll wonder why the network keeps extending it, because the network should drop invalid blocks. So if it is above a certain length, the node will give a warning to the user, because the most likely reason is a hardfork which requires a client software upgrade Jul 15, 2017 at 7:22