Allow untrimming headers when needed

This commit is contained in:
Pablo Greco 2023-09-29 12:04:59 -07:00 committed by James Dorfman
parent 4259278ff5
commit c28c5ce619
5 changed files with 40 additions and 0 deletions

View file

@ -56,6 +56,20 @@ CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
return CBlockLocator(vHave);
}
void CBlockIndex::untrim() {
if (!trimmed())
return;
CBlockIndex tmp;
const CBlockIndex *pindexfull = untrim_to(&tmp);
assert(pindexfull!=this);
m_trimmed = false;
set_stored();
proof = pindexfull->proof;
m_dynafed_params = pindexfull->m_dynafed_params;
m_signblock_witness = pindexfull->m_signblock_witness;
m_pcontext->chainman->m_blockman.m_dirty_blockindex.insert(this);
}
const CBlockIndex *CBlockIndex::untrim_to(CBlockIndex *pindexNew) const
{
return m_pcontext->chainman->m_blockman.m_block_tree_db->RegenerateFullIndex(this, pindexNew);