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?
-
1One would probably need the entire chain to avoid double-spend-transactions in the newly mined block?– tobixenOct 28, 2015 at 14:55
-
related: Mini-Blockchain proposal: How is the proof-chain secured against injections?, If more than one coin did the “mini-blockchain” proposal, would that make the weaker coin vulnerable?– Murch ♦Nov 3, 2015 at 23:33
1 Answer
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.
This has a couple implications:
- You need to download and process the whole blockchain before you can start mining (provided you only want to produce valid blocks).
- 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. - 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.
-
2Unless, 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