channeldb: export DB migration related functions

We'll need to know whether a database was migrated to the latest version
in our upcoming data migration tool. To be able to determine the current
version of a DB and the total number of migrations in existence, we need
to export some of the functions in channeldb.
We also add some helper functions for adding tombstone and other markers
to a database.
This commit is contained in:
Oliver Gugger
2022-09-30 14:17:13 +02:00
parent 28c8e8b6dd
commit 7e76326b97
3 changed files with 189 additions and 7 deletions

View File

@@ -438,7 +438,7 @@ func initChannelDB(db kvdb.Backend) error {
err := kvdb.Update(db, func(tx kvdb.RwTx) error {
meta := &Meta{}
// Check if DB is already initialized.
err := fetchMeta(meta, tx)
err := FetchMeta(meta, tx)
if err == nil {
return nil
}
@@ -1561,6 +1561,12 @@ func (d *DB) ChannelStateDB() *ChannelStateDB {
return d.channelStateDB
}
// LatestDBVersion returns the number of the latest database version currently
// known to the channel DB.
func LatestDBVersion() uint32 {
return getLatestDBVersion(dbVersions)
}
func getLatestDBVersion(versions []mandatoryVersion) uint32 {
return versions[len(versions)-1].number
}