Due to recent performance optimisations to the difficulty iterator, a call to the chain's get_header_by_height needed to be added. Unfortunately, this function relies on a read lock on the txhashset. A write lock is held unyielded for a very long time by validation code after the txhashset is downloaded, leading to a TUI freeze when calling this method.
Fix is to avoid that call by re-adding a hash to the HeaderDifficultyInfo struct, populated by maintaining hashes as provided in the prev_header field in the Headers themselves. This optionally keeps hashes available in the HeaderDifficultyInfo struct while still avoiding the need to deserialize the entire header to derive the hash.
Note this point in the TUI code is the only place where a block's hash is needed from the DifficultyIterator, so impact should be minimal.
Due to recent performance optimisations to the difficulty iterator, a call to the chain's
get_header_by_height
needed to be added. Unfortunately, this function relies on a read lock on the txhashset. A write lock is held unyielded for a very long time by validation code after the txhashset is downloaded, leading to a TUI freeze when calling this method.Fix is to avoid that call by re-adding a hash to the
HeaderDifficultyInfo
struct, populated by maintaining hashes as provided in theprev_header
field in the Headers themselves. This optionally keeps hashes available in theHeaderDifficultyInfo
struct while still avoiding the need to deserialize the entire header to derive the hash.Note this point in the TUI code is the only place where a block's hash is needed from the DifficultyIterator, so impact should be minimal.