Implements the idea discussed in #29652 (comment)
Currently, m_last_block_processed
and m_last_block_processed_height
are not guaranteed to match the block locator stored in the wallet, nor do either of those fields actually represent the last block that the wallet is synced up to. This is confusing and unintuitive.
This PR changes the those last block fields to actually be in sync with the record stored on disk. This requires adding the block height to the BESTBLOCK_NOMERKLE
record, which was done in a backwards compatible manner. Additionally, the issue with chainStateFlushed
fixed in #29652 is also fixed here by removing chainStateFlushed
entirely. The last block fields, now simply the best block, is updated for each blockConnected
and blockDisconnected
so that it does actually represent the block for which the wallet is synced up to.
To make it easier to deal with, the best block fields are consolidated into a BestBlock
struct which also has the serialization code with backwards compatibility.