(I've also included some questions)
1. When a new block has been successfully mined, it is propagated throughout the network for nodes to validate.
2. When a node receives a newly mined block, it:
- validates all the transactions contained in the block by cross-checking them against its version of the blockchain;
- validates the whole block by running the PoW algorithm to check that adding the block to its version of the blockchain generates the same hash value.
3. If the same node subsequently receives a valid competing block (to the one just validated and added in 2. above), will it immediately replace the previously added block (which would then become a stale block) if the competing block has a higher difficulty? Or will it also add the valid competing block and temporarily maintain a split version of the blockchain until it receives another valid block which links cryptographically to one of the two branches, discarding at this point the block on the "shorter" branch?
4. Each node also continuously compares its growing version of the blockchain with the versions maintained by the other nodes it communicates with.
If a node discovers a version that is "longer" (in terms of total difficulty, not necessarily number of blocks), does the protocol require it to automatically add the other version's additional, or different, block(s), and to discard any blocks included in its own version which are excluded from the other (which would then become stale blocks)? Or does each node decide for itself if and when to amend its own version in this way? For example, could it decide to wait to make such amendments until a certain number of blocks have been added to the other node's "different" block(s)?
Does this have anything to do with the process of synching?
I'd really appreciate some more clarity on these points... I've been tying myself up in knots trying to reason it all through...