calculating block id
Right now a block id is calculated by taking the hash of:
- parent block id
- timestamp
- nonce
- miner address
- transaction merkle root
This should change to:
- block merkle root
- parent block id
- nonce
Where the block merkle root is 32 bytes, the parent block id is 32 bytes, and the nonce is 8 bytes. The block merkle root is composed of:
- timestamp
- miner payout slice (see #301 (closed))
- transaction merkle root
This change will make it much easier to do efficient mining, efficient verification, and efficient headers-first
This makes makes it easier to do efficient mining and verification, and also easier to do fast headers-first communications. Mining now requires hashing 72 bytes per id, which is less than before and therefore should be faster (we might want to benchmark this though). Headers-first communication only requires 40 bytes per block (the block merkle root and the nonce, because the parent id can be assumed), which allows you to build up a chain that looks like the most-work chain very quickly. You can verify the block work level without needing the information about the timestamp and miner address and transaction merkle root, which saves you bandwidth.
You can't be sure that the block has followed the rules, and you can't be sure what the target was supposed to be, but you can get an estimate for how much total work happened. If necessary, you can sling in an extra 2 bytes for an approximate timestamp (number of seconds different from previous timestamp) which makes 42 bytes per block during headers-first.