Mastering Ethereum
上QQ阅读APP看书,第一时间看更新

Proof-of-work

This is a method to guarantee that the result of a task was hard to achieve. Why do we want to make processing tasks difficult? To reward those that are best at completing it. In a blockchain, it costs processing power, which is just hardware, energy, and time, to process transactions made by individuals using the network. It is used to generate blocks in a simple process:

  • The miner proposes a new block that contains a hash number made of the header of the most recent block and the nonce counter.
  • Then, the miner compares the hash to the target value which is determined by the mining difficulty.
  • If the hash is of the target difficulty, the user gets rewarded with the solution by getting ETH. If not, the nonce gets incremented until a hash is generated with the desired solution.

Since the miner will be competing with many others, there must be a system to make sure that the block times are consistent, because we want to keep generating blocks with the same periodicity even when new nodes join the mining network. To guarantee similar block times, the mining difficulty was created.