anders94 / blockchain-demo

A web-based demonstration of blockchain concepts.
MIT License
5.12k stars 2.56k forks source link

Changing block's data also changes next block's previous hash #106

Closed AkashKarnatak closed 1 year ago

AkashKarnatak commented 1 year ago

If I tamper block 4's data then it's hash will change. But why does block 5's previous hash gets affected? Screenshot 2022-10-14 at 21-34-08 Blockchain Demo

I expect it to remain the same like so. Screenshot 2022-10-14 at 21-38-48 Blockchain Demo

anders94 commented 1 year ago

This is expected behavior. The previous hash is calculated from the previous block, not something set by that block. If it doesn't change then there is no integrity guarantee being established and the usefulness of a blockchain disappears.