From f582eab1fa367ab1895bb7c4a0097030d8c9b0de Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Fri, 2 Nov 2018 18:43:27 -0700 Subject: [PATCH] waddrmgr: remove old migration logic In this commit, we remove the old upgrade/migration logic of the address manager as it's been superseded by the new approach using the migration.Manager interface. --- waddrmgr/db.go | 44 -------------------------------------------- waddrmgr/manager.go | 8 -------- 2 files changed, 52 deletions(-) diff --git a/waddrmgr/db.go b/waddrmgr/db.go index 14a61a3..851410b 100644 --- a/waddrmgr/db.go +++ b/waddrmgr/db.go @@ -11,7 +11,6 @@ import ( "fmt" "time" - "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcwallet/walletdb" ) @@ -2101,46 +2100,3 @@ func createManagerNS(ns walletdb.ReadWriteBucket, return nil } - -// upgradeManager upgrades the data in the provided manager namespace to newer -// versions as neeeded. -func upgradeManager(db walletdb.DB, namespaceKey []byte, pubPassPhrase []byte, - chainParams *chaincfg.Params, cbs *OpenCallbacks) error { - - var version uint32 - err := walletdb.View(db, func(tx walletdb.ReadTx) error { - ns := tx.ReadBucket(namespaceKey) - var err error - version, err = fetchManagerVersion(ns) - return err - }) - if err != nil { - str := "failed to fetch version for update" - return managerError(ErrDatabase, str, err) - } - - if version < 5 { - err := walletdb.Update(db, func(tx walletdb.ReadWriteTx) error { - ns := tx.ReadWriteBucket(namespaceKey) - return upgradeToVersion5(ns) - }) - if err != nil { - return err - } - - // The manager is now at version 5. - version = 5 - } - - // Ensure the manager is upraded to the latest version. This check is - // to intentionally cause a failure if the manager version is updated - // without writing code to handle the upgrade. - if version < latestMgrVersion { - str := fmt.Sprintf("the latest manager version is %d, but the "+ - "current version after upgrades is only %d", - latestMgrVersion, version) - return managerError(ErrUpgrade, str, nil) - } - - return nil -} diff --git a/waddrmgr/manager.go b/waddrmgr/manager.go index a2f8962..d9c82b7 100644 --- a/waddrmgr/manager.go +++ b/waddrmgr/manager.go @@ -1522,14 +1522,6 @@ func Open(ns walletdb.ReadBucket, pubPassphrase []byte, return loadManager(ns, pubPassphrase, chainParams) } -// DoUpgrades performs any necessary upgrades to the address manager contained -// in the wallet database, namespaced by the top level bucket key namespaceKey. -func DoUpgrades(db walletdb.DB, namespaceKey []byte, pubPassphrase []byte, - chainParams *chaincfg.Params, cbs *OpenCallbacks) error { - - return upgradeManager(db, namespaceKey, pubPassphrase, chainParams, cbs) -} - // createManagerKeyScope creates a new key scoped for a target manager's scope. // This partitions key derivation for a particular purpose+coin tuple, allowing // multiple address derivation schems to be maintained concurrently.