2

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:

  • legacy inv mechanism, in which case just block hashes are announced
  • BIP130 (if negotiated), in which case announcements send full block headers
  • BIP152 high-bandwidth mode (if negotiated), in which case blocks are immediately transferred in full using compact blocks protocol
  • 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 Oct 22 '17 at 20:05
  • 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 Oct 22 '17 at 20:14
  • Can we continue in chat.stackexchange.com/rooms/67480/bitcoin-chain-progression – croraf Oct 22 '17 at 20:36
  • What stops me from tampering with a new block (I created), before it is distributed to the rest of the nodes? – daka May 11 '18 at 12:29
  • @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 May 11 '18 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.