I am trying to get my head around how blockchains work.
I have two blocks in my blockchain:
Block #0 has been added to the blockchain! Hash: b3bc62c2b75e70fcc3fe709a5e724c7230d89bb70db17c1d2f5c3687b44b4c31 Block #1 has been added to the blockchain! Hash: 76915298f65b261dbe8b5e2300c77b13966a8dd68175e49ffe5cbc59b055042d
The hash is derived from passing the block's timestamp, data and the previous block's hash through sha256. I understand that if I am in the middle of a blockchain and then try to modify the data the other blocks will be corrupt because the hash won't be correct. E.g. I modify block 2, change the data and even generate a new hash using the correct function, this will invalidate block 3's hash because the previous hash won't generate the correct hash for block 3.
However if I modify the last block in the chain how does it work? I can just change the data and generate a new hash, there is no next hash to verify it.
Any clarification on how this works would be great! Thanks!