Final block

A Twine byte stream can end with a finalizer block, which is used to provide the entrypoint into the DAG. In other words, this entrypoint is the toplevel, outermost value that was serialized via Twine. It is often an array of map.

The last byte of a twine stream with finalizer, at offset p == twine_string.len()-1, is a u8 delta. If twine_string[p] == n, then twine_string[p-n-1] must be a valid twine value. The entrypoint, if it fits in less than 256 bytes, can be stored directly this way; otherwise, a pointer to the entrypoint is stored instead.

For a large entrypoint at offset p_e, then, the finalizer block is:

offsetvalue
p_eentrypoint value
p_ptrPointer(p_e)
p(p - p_ptr_e - 1) as u8