blockchain: Flush UTXO DB after init utxoSetState.

This forces the UTXO database to flush to disk after initializing the
UTXO set state for the first time.  This is necessary so that if the
block database is flushed, and then an unclean shutdown occurs, the UTXO
cache will know where to start from when recovering on startup.
This commit is contained in:
Ryan Staudt 2021-05-07 13:50:52 -05:00 committed by Dave Collins
parent 0bf463d7d5
commit 0d935b2717

View File

@ -717,6 +717,15 @@ func (c *UtxoCache) Initialize(b *BlockChain, tip *blockNode) error {
if err != nil {
return err
}
// Flush the UTXO database to persist the initialized state. This is
// necessary so that if the block database is flushed, and then an unclean
// shutdown occurs, the UTXO cache will know where to start from when
// recovering on startup.
err = c.db.Flush()
if err != nil {
return err
}
}
// Set the last flush hash and the last eviction height from the saved state