11

I understand that to mine bitcoins you need the hash of the previous block, and in order to resolve possible forks. But why not just have the last 100 blocks (or more whatever is appropriate) and keep a sliding window of the last blocks?

2

1 Answer 1

11

To mine a valid block, you need to ensure that every Bitcoin transaction in your block is valid. Because each transaction (except for coinbase transactions) spends the output from a previous transaction, you need to have processed every previous transaction in the blockchain.

Transaction output to input

This has a couple implications:

  1. You need to download and process the whole blockchain before you can start mining (provided you only want to produce valid blocks).
  2. You can create a database of just the information you need to validate future transactions and only store that, allowing you to get rid of the rest of the blockchain data you downloaded and processed. Bitcoin Core 0.11.0 began supporting this blockchain data pruning feature for mining with the -prune parameter.
  3. You can outsource validation of transactions to someone else and only mine the transactions they say are valid. This way you don't need to store any blockchain data at all. This is what most pool miners do.
1
  • 2
    Unless, of course, you want to mine blocks with no transactions in them at all. In that case, you could just assume the longest chain contains only valid transactions. It's anti-social, but as long as you care only about the block reward and not everyone does it, it will work. Mar 31, 2016 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.