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 7, 2018 in Blockchain by Shashank
• 10,350 points
32 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 7, 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 13, 2018 in Blockchain by Shashank
• 10,350 points
30 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,550 points
56 views
+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,080 points
88 views
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
173 views
0 votes
1 answer
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 127 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
90 views