How blockchain nodes switches to another chain

+1 vote
suppose at a certain point of time a node finds out that it is having the wrong chain and there is no longer chain available.

How does a node switch to the longest chain. Imagine that the node has to run all transactions in reverse till the fork happened to restore the state and then replay all transactions in the blocks from the longer chain.?
Apr 8, 2018 in Blockchain by Shashank
• 10,400 points
625 views

1 answer to this question.

+1 vote
Best answer

Each individual transaction is validated by every nodes which receives it. After validation the transactions propagates further to its connecting peers. The validation process involves several steps. In one of those steps the node verifies if the block points to the most recent block in the chain. The nodes also ensures that the transactions included in the blocks are valid. Now, coming on to your query. "you asked that what happens in the case when a node realizes that it was on the wrong chain and there is longer chain available, which forked some blocks before." How does it make the switch? I imagine that it should run all transactions in reverse till the fork happened to restore the state and than replay all transactions in the blocks from the longer chain? Forking is a rare situation that happens when a network receives two valid blocks. Suppose a node received two blocks at the same time, now it doesn't know which block os the right one. It adds one block to its main chain and the other block will be added to the forked chain. Now the node will wait for the next block to be found by the network, once this next block is found, the node will check for the longest chain available in the network, and will add this incoming block to the chain. and the blocks which are there in the shorter branches will go to the pool of unconfirmed transactions and are then picked up again later by the miners in the main chain.

answered Apr 8, 2018 by Christine
• 15,790 points

selected Aug 6, 2018 by Omkar

Related Questions In Blockchain

0 votes
1 answer

How to handle memory and processor limitations of nodes in blockchain?

Yes, that's a valid concern. The Bitcoin ...READ MORE

answered Jul 14, 2018 in Blockchain by Shashank
• 10,400 points
536 views
0 votes
1 answer

How to call function in one contract from another contract in private blockchain?

Please check whether you have byzantiumBlock: 0 in your ...READ MORE

answered Oct 1, 2018 in Blockchain by digger
• 26,740 points
705 views
0 votes
1 answer

On-Chain NFT: How to store a pixel image on the ethereum blockchain?

The images are usually not stored in ...READ MORE

answered Feb 24, 2022 in Blockchain by Aditya
• 7,680 points
855 views
0 votes
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,705 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,237 views
0 votes
1 answer

How to make sure transactions take no fee in a private Ethereum blockchain?

In a private ethereum network you have ...READ MORE

answered Mar 26, 2018 in Blockchain by Christine
• 15,790 points

edited Mar 26, 2018 by Christine 1,364 views
0 votes
1 answer

How to create a new wallet on a blockchain?

Firstly, you need to have a clear ...READ MORE

answered Apr 4, 2018 in Blockchain by Christine
• 15,790 points
1,119 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP