Posts

Understanding Blockchain - Final Part

avatar of @menoski
25
@menoski
·
0 views
·
3 min read

Hello everyone, hope you all are doing good? I'm back with the Final Part of this amazing series, Understaning Blockchain. If you haven't read the Part 1, Part 2, Part 3 and Part 4, I strongly suggest you that by clicking here for Part 1, here for Part 2, here for Part 3 and here for Part 4. In today's article we would be looking at how Block Hashes works in blockchain visually, by visiting a Blockchain Demo site.



From the image above, you notice some features of the page, such Block, Nonce, Data, Prev and Hash. The standout features for us are Prev and Hash.

Take a look at Block 1, you will notice the Prev is just 0000... and the Hash is unique. Now, look at Block 2, you will notice that the Prev is the unique Hash of Block 1, and it produces a new Hash. Meaning Block 2 took note of Block 1 hash.

To prove this even further, here is a screenshot of Block 3 and Block 4 below. You will notice that the Prev of Block 3 will be the Hash of Block 2, and the Prev of Block 4, will be the Hash of Block 3. And that's how it comes on and on.



This is why blockchain data are mostly immutable, because each block takes note of the previous block hash, to create a new Hash.


Adding Data

You will notice that the previous screenshots had no data stored. But as soon as you add data, the blockchain will have to generate a new hash for that data. Let's take for instance, I add Menoski to the data section of Block 1, let's see what will happen.



The Hash remained the same, right? But the background of the page changed from Green to Red, meaning something is wrong. But what exactly?

What is wrong, is that, the hash that exists for Block 1, was an empty data, and since new data has been added, there's need to mine, in order to generate a new hash that suits the new data that has been added. Let's take for instance, I click on Mine, let's see what will happen.



A new Hash was generated and the background color for Block 1 changed to green, meaning, everything is okay with Block 1. But why is Block 2, still red? This is because, as soon as you add a new data, the hash of that block changes, hence, the Prev of the next block won't be same with Hash of the current Block. So, you must have to Mine, all the blocks afterwards, so that, the Prev hash, matches the Hash of the previous block.





What will happen when any middle of the block gets changed

What if any middle block gets changed, what I will happen? Alright, let's add data to Block 3, that is right in the middle, between Block 1 - 2 and Block 4 - 5. By adding data to Block 3, that's a change, because the Data section was empty before. Let's a add Stream4u and see what happens.



From the image, above, you will notice that from Block 3 - 5, the background color changed to Red, meaning something is wrong. While from Block 2 to Block 1, background color remained Green, meaning everything is okay, but why?

It is quite simple, the Prev on Block 3 won't be affected but the Hash for block 3 will have to change because a new data has been added. So, if the new data is added, the Hash of Block 3 will change, the Prev of Block 4 and Block 5 will also need to change, because the Prev of Block 4 will have to be updated to the new Hash of Block 3 and the Prev of Block 5 will also have to change to the new Hash of Block 4. Block 1 and 2 remain unaffected, because both their Prev and Hash won't be affected.



So, I will have to mine Block 3, 4 and 5 for everything to be okay and functioning properly. You can clearly see why Blockchain data are almost impossible to be altered. Because if you want to change any Data from the past, you will have to start mining(change) all the Hashes after that the Block you altered, which is almost an impossible task.


I hope you now fully comprehend how Block hashes works in Blockchain and what will happen when any middle of the block gets changed.


I hope you all found the article interesting and exciting. Do well to share your thoughts about the article in the comment section below. Thanks.

⚫️⚪️⚫️

Thanks For Reading

Till Next Time, Stay Safe