Let’s say the valid blockchain that Node A has is:B1->B2->B3
Now, I am gonna cheat since I have lots of computing power. What I do is I download the above blockchain that Node A has and start cheating. Before I do that, I make a transaction to buy a motorbike. so,
valid blockchain now looks like this(B1->B2->B3->B4) . B4 has my bike transactions. In my local copy, I didn’t put that transaction . Now, because i want to have a longest chain, i work so fast and let’s say after a while Node A’s chain and mine looks like this:
Node A – B1->B2->B3->B4->B5
Mine – B1->B2->B3->O1->O2->O3->04
Now, I want to broadcast my chain.
What do I broadcast ? the whole chain (B1->B2->B3->O1->O2->O3->04) or only O1->O2->03->04 ?
A) If I broadcast only O1->O2->03->04 , how does node A figure out that it has to remove B4->B5 only from its chain and append O1->O2->03->04 to B3 ? Does it first get O1’s prev hash and then in its local blockchain, it searches the block with that hash and if it finds, it removes every block after it and appends the newly copied O1->O2->03->04 from my chain. ? if so, it would also account for if the new one is the longest one (so the count of the removals of the blocks should be less than the count of new copied blocks).. Am I right ?
B) of course, broadcasting the whole chain is out of question since it’s so huge.