Is the following an accurate summary of what happens?
(I’ve also included some questions)
-
When a new block has been successfully mined, it is propagated throughout the Bitcoin network for nodes to validate.
-
When a node receives a new block, it validates it by running the PoW algorithm to check that adding the new block to its version of the blockchain generates the same hash value. If it doesn’t, then the block is rejected. If it does, then it’s added to the node’s own version of the blockchain, and propagated to other nodes.
-
If a node subsequently receives a valid competing block (to the one just validated and added as 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 a valid block which links mathematically to one of the two branches, discarding at this point the block on the “shorter” branch?
-
Each node also continuously compares its growing version of the entire blockchain with the versions maintained by the other nodes it communicates with.
If a node discovers a version that is “longer” than its own, does it automatically add the other version’s additional block(s), and discard any blocks included in its own version which are different (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?
If a node discovers a version that isn’t “longer” in terms of number of blocks, but does have a different final block, rather than just decide arbitrarily, will it choose the version with the highest total difficulty? (I think this is what @ivan explains, in the Blockchain & Bitcoin 101 lecture on stale blocks, as being what the decision is actually based on, rather than “length” in terms of number of blocks).
I’d really like to get some more clarity on these points…