CHAPTER 9Mining

Bitcoin mining was introduced in section 7.4, in the context of the blockchain. Mining is the process of adding blocks to the blockchain. Miners contribute their computational power to solve the blocks that are added to the blockchain, and the network remunerates them with the block reward and the fees collected from all the transactions included in the block.

Miners solve the partial hash inversion problem. To find a solution, mining software usually increments the block nonce and runs the proof-of-work algorithm to check if the chosen nonce generates a correct block hash (i.e. a block hash that meets the difficulty requirements)1.

A typical optimization used by miners is to pre-compute the hash of the initial part of the block header that contains the previous block hash and the root of the Merkle transaction tree (section 7.6). This part of the block header is constant during the mining process and therefore can be stored in a buffer.

One of the advantages of the mining mechanism is that it rewards early adopters for supporting the network. This was very important in the beginning, when Bitcoin bootstrapped itself into relevance. Bitcoin does not have a corporation backing it, so marketing had to be done virally. This would have been impossible without the help of early adopters. Rewarding miners is a way to enlist them to create word of mouth.

Mining is similar to a market with perfect competition: as long as there is profit to be made, new entrants will ...

Get Understanding Bitcoin: Cryptography, Engineering and Economics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.