From c523ccd19216c5f9f8b6eb3fed3f8d767116a186 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Fri, 2 Nov 2018 18:43:09 -0700 Subject: [PATCH] wtxmgr/db: remove LatestVersion const in favor of getLatestVersion In this commit, we can remove the LatestVersion constant as it's no longer needed. Instead, we'll now define the latest version as the last entry in the slice of versions previously defined. --- wtxmgr/db.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/wtxmgr/db.go b/wtxmgr/db.go index 43a1714..6ebe9df 100644 --- a/wtxmgr/db.go +++ b/wtxmgr/db.go @@ -52,13 +52,6 @@ import ( // keys iterating in order. var byteOrder = binary.BigEndian -// Database versions. Versions start at 1 and increment for each database -// change. -const ( - // LatestVersion is the most recent store version. - LatestVersion = 1 -) - // This package makes assumptions that the width of a chainhash.Hash is always // 32 bytes. If this is ever changed (unlikely for bitcoin, possible for alts), // offsets have to be rewritten. Use a compile-time assertion that this @@ -1269,14 +1262,15 @@ func openStore(ns walletdb.ReadBucket) error { return err } - if version < LatestVersion { + latestVersion := getLatestVersion() + if version < latestVersion { str := fmt.Sprintf("a database upgrade is required to upgrade "+ "wtxmgr from recorded version %d to the latest version %d", - version, LatestVersion) + version, latestVersion) return storeError(ErrNeedsUpgrade, str, nil) } - if version > LatestVersion { + if version > latestVersion { str := fmt.Sprintf("version recorded version %d is newer that "+ "latest understood version %d", version, latestVersion) return storeError(ErrUnknownVersion, str, nil)