5

I'm trying to understand how mining works and I'm stuck on the part about validating blocks and adding them to the blockchain.

When a miner finds a solution to a block, he shares it with the network, where other miners validate his new block by checking if the hash of the block (using the found nonce) is smaller than the target, right?

At which point does the validation of the block happen and how many users do have to validate the block so it gets appended to the blockchain?

Does this happen before a miner creates a new block? So basically he'd take a new block in the network, validate it, if it's okay, he takes that one as his "previous block" reference?

5

A block is checked in two places: First, it's checked before a miner starts working on it, and second, it's checked by every other node before accepting the block as valid.

2

The thing you have to keep in mind is that there isn't just one chain. Every individual running a full node has their own chain, and validates all the blocks on it as they receive them from the miners. If a block is invalid, full nodes and other miners will ignore it, and not include it in their own chains. It is possible that two nodes disagree on which block is the head of the chain.

This type of fork happens about once per day, where half the network thinks block A is the real block, and half the network thinks block B is the real block. This is perfectly fine, and resolves itself when either block A + 1 or block B + 1 is found. The protocol dictates that nodes accept the longest chain as the real chain, and alternative chains get removed.

The answer to this question may help you understand.

0

There are valid blocks and there are confirmed blocks. A block is valid if a miner solves the hash puzzle and has included all valid transactions. However, The block is only confirmed once it is firmly part of the longest chain, i.e. there's no chance it can become orphaned. In this case we can say all nodes have reached consensus. The default for bitcoin clients is to wait 6 blocks. And newly mined/minted coins cannot be spent for 100 blocks.

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.