2
1
When does bitcoin node sync itself?
Do different types of sync in bitcoin exist (initial, periodic...)?
2
1
When does bitcoin node sync itself?
Do different types of sync in bitcoin exist (initial, periodic...)?
5
Always.
When starting up, Bitcoin Core sends out a request to its peers to inform it about the best chains they know about (using a getheaders message).
After that point, it is automatic: peers will immediately announce new blocks they knew about after they learn about them. This either happens using:
inv mechanism, in which case just block hashes are announced
I was thinking more about the following: If the node (for some reason) missed a block from main branch or a side branch, he will be out of sync. And he will reject all blocks mined on top of these branches? He must perform some kind of sync. Is this done only when disconected/reconected or periodically? – croraf – 2017-10-22T20:05:19.783
Your node always works towards the best valid block it knows about. If it learns about a side branch that grows longer than the best block it knew about before, it will download it, and rewind the current block chain to the forking point, and then connect the new best. If the new branch turns out to be invalid, it will revert back to the older tip. All that also happens all the time - we always want to have the best possible block active. – Pieter Wuille – 2017-10-22T20:14:14.950
Can we continue in https://chat.stackexchange.com/rooms/67480/bitcoin-chain-progression
– croraf – 2017-10-22T20:36:24.307What stops me from tampering with a new block (I created), before it is distributed to the rest of the nodes? – daka – 2018-05-11T12:29:07.063
@daka That depends on what you mean by tampering. If you modify the block is a legal way before grinding the PoW, it will just be valid. If you make an illegal modification (double spend, theft, inflation, ...), the block will be invalid no matter what. If you modify a block after grinding, you invalidate the PoW, and you'll have to redo it. – Pieter Wuille – 2018-05-11T13:00:32.823
"the block will be invalid no matter what" why is that? could you please elaborate on this? thanks – daka – 2018-05-11T13:16:08.313
Because all full nodes verify all transaction in a block before accepting. The rule is that the longest valid chain wins; not just the longest one regardless of its contents. – Pieter Wuille – 2018-05-11T13:26:51.767