mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-19 20:15:18 +02:00
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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user