Here's how the C++ code calculates the block digest:
digest_type::hash(*this)
serializes the block into a binary form, then runs the binary through sha-256.- block.hpp#L125 identifies the order that the fields are serialized in.
- The types of these fields is at block.hpp#L18
- Each type has its own serialization procedure. Most of them live in libraries/fc.
- Here's an example of how it serializes an
unsigned_int
. This is a 32-bit type which serializes to 1-5 bytes depending on value: raw.hpp#L210
Note: many users of the JSON RPC API have to serialize objects to binary form, so I suspect someone will create documentation of this process.
Note: the block fields may still change. I pointed to the master branch as of 2018-05-08.