Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Sep 27, 2023
1 parent 1bad3a4 commit 905e659
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 3 additions & 3 deletions server/migrate_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ the new application db will use plain DB store types.
if err != nil {
return err
}
fmt.Printf("Multi root store is dumped at version %d \n", version)
fmt.Printf("Multi root store is captured at version %d \n", version)

_ = db.Close()
_ = newDb.Close()
Expand All @@ -80,10 +80,10 @@ the new application db will use plain DB store types.
if err = os.Rename(applicationMigratePath, applicationPath); err != nil {
return err
}
fmt.Printf("Database is replaced and the old one is backup %s\n", applicationBackupPath)
fmt.Printf("Application db is replaced and the old one is backup %s\n", applicationBackupPath)

_ = os.Remove(applicationMigratePath)
fmt.Printf("Migrate database done, please update app.toml and config.toml to use fastnode feature")
fmt.Printf("Migrate application db done, please update app.toml and config.toml to use fastnode feature")

return nil
},
Expand Down
8 changes: 1 addition & 7 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,14 @@ func (rs *Store) MigrateStores(targetType types.StoreType, newDb dbm.DB) error {
return errors.New("only StoreTypeDB is supported")
}

batch := newDb.NewBatch()
defer batch.Close()

for key, store := range rs.stores {
switch store.GetStoreType() {
case types.StoreTypeIAVL:
rs.logger.Info("Migrating IAVL store", "store name", key.Name())
iterator := store.Iterator(nil, nil)
for ; iterator.Valid(); iterator.Next() {
prefixKey := append([]byte("s/k:"+key.Name()+"/"), iterator.Key()...)
if err := batch.Set(prefixKey, iterator.Value()); err != nil {
if err := newDb.SetSync(prefixKey, iterator.Value()); err != nil {
return err
}
}
Expand All @@ -161,9 +158,6 @@ func (rs *Store) MigrateStores(targetType types.StoreType, newDb dbm.DB) error {

}
}
if err := batch.WriteSync(); err != nil {
return err
}
return nil
}

Expand Down

0 comments on commit 905e659

Please sign in to comment.