I reference to the python implementation (https://github.com/ethereum/pyethereum/blob/develop/ethereum/block.py). What you can see there is the following list of tuples:
fields = [
('prevhash', hash32),
('uncles_hash', hash32),
('coinbase', address),
('state_root', trie_root),
('tx_list_root', trie_root),
('receipts_root', trie_root),
('bloom', int256),
('difficulty', big_endian_int),
('number', big_endian_int),
('gas_limit', big_endian_int),
('gas_used', big_endian_int),
('timestamp', big_endian_int),
('extra_data', binary),
('mixhash', binary),
('nonce', binary)
]
Now we have to go through three steps to get our block hash:
- Serialize the Block object.
The field variable is a list containing tuples. This can be considered as an dictionary, containing key to value mappings like 'prevhash' -> hash32. The serialization is in this case a process where a list is created and appended by only the values of the dictionary (in the correct order). So what you are left with after the serialization is a list containing the values for the following descriptive key words:
['prevhash', 'uncles_hash', 'coinbase', 'state_root', 'tx_list_root', 'receipts_root', 'bloom', int256), 'difficulty', 'number', 'gas_limit', 'gas_used', 'timestamp', 'extra_data', 'mixhash', 'nonce']
- Apply RLP encoding on the serialized "Block" object.
- Get the Keccak-256 hash from the result of the RLP encoding from step 2. The resulting hash is the block hash you were looking for.