0

I know that the transactions stay in the block and hashed alongside few other things and that hash is stored in the next block. And I understand that if you try to tamper with one of the transactions, the hash will change and it will affect all the blocks that come after it.

However, how does a block know that its transactions have tampered with in the first place?

Assume that block #1000 has 10 transactions. Now, the hash has been calculated and stored in block #1001

so, if I go back to block #1000 and add one more transaction, this will change the hash and it wont be the same one stored in #1001. However, how the hash of block #1000 changes in the first place if it was already calculated? does this mean that the hash of each block is recalculated regularly?

  • 1
    what makes you think you can "add" a transaction to a block? the miner chooses what goes in the block. a miner can mine with your transaction included or excluded, but if he includes it, he can get the fees. somebody might find another block at the same height, that doesn't include your transaction but has high enough difficulty. but the security assumption is that it's hash will be different. – Janus Troelsen Sep 23 at 23:11
0

Hashes don't actually 'change'. When you add a transaction to a block you are creating another block.

It's like an author published a book and then next year printed a new edition with an extra comma in the page 36 and the fans said he released a 'new' book. It doesn't make sense for books but for blockchain every bit counts.

0

If I go back to block #1000 and add one more transaction, this will change the hash and it wont be the same one stored in #1001. However, how the hash of block #1000 changes in the first place if it was already calculated?

Once a block has been mined and accepted as part of the longest valid chain (ie, several confirmations deep), it will not ever change (which means the block's contents, and thus hash, will not change).

In order to change it, you would have to also change every block that comes after it, all the way up until the current chain tip. This would take a huge amount of computational power to pull off, you would basically need to 51% attack the network, to re-write the blockchain history. This sort of attack is extremely expensive, and ignores the incentives for mining honestly, you can read more about it here.

Otherwise, if you just changed block #1000, and then attempted to broadcast the changed block to your peers, they will all reject that block, since it is not part of the longest valid chain (assuming they have already heard about the original block #1000, and all of the blocks that came after it).

does this mean that the hash of each block is recalculated regularly?

A block's hash will be calculated in order to determine its validity, but we would never expect the hash to change for a block that has a sufficient number of confirmations on the network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.