44 "errors"
55 "fmt"
66
7+ "github.com/btcsuite/btcd/chaincfg"
78 "github.com/coreos/bbolt"
89)
910
@@ -24,14 +25,17 @@ var (
2425// migration is a function which takes a prior outdated version of the database
2526// instances and mutates the key/bucket structure to arrive at a more
2627// up-to-date version of the database.
27- type migration func (tx * bbolt.Tx ) error
28+ type migration func (tx * bbolt.Tx , chainParams * chaincfg. Params ) error
2829
2930var (
3031 // dbVersions is storing all versions of database. If current version
3132 // of database don't match with latest version this list will be used
3233 // for retrieving all migration function that are need to apply to the
3334 // current db.
34- migrations = []migration {migrateCosts }
35+ migrations = []migration {
36+ migrateCosts ,
37+ migrateSwapPublicationDeadline ,
38+ }
3539
3640 latestDBVersion = uint32 (len (migrations ))
3741)
@@ -76,7 +80,7 @@ func setDBVersion(tx *bbolt.Tx, version uint32) error {
7680// syncVersions function is used for safe db version synchronization. It
7781// applies migration functions to the current database and recovers the
7882// previous state of db if at least one error/panic appeared during migration.
79- func syncVersions (db * bbolt.DB ) error {
83+ func syncVersions (db * bbolt.DB , chainParams * chaincfg. Params ) error {
8084 currentVersion , err := getDBVersion (db )
8185 if err != nil {
8286 return err
@@ -112,7 +116,7 @@ func syncVersions(db *bbolt.DB) error {
112116 log .Infof ("Applying migration #%v" , v + 1 )
113117
114118 migration := migrations [v ]
115- if err := migration (tx ); err != nil {
119+ if err := migration (tx , chainParams ); err != nil {
116120 log .Infof ("Unable to apply migration #%v" ,
117121 v + 1 )
118122 return err
0 commit comments