Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions node/app/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ var keyManagerSet = wire.NewSet(

var storeSet = wire.NewSet(
wire.FieldsOf(new(*config.Config), "DB"),
store.NewPebbleDB,
wire.Bind(new(store.KVDB), new(*store.PebbleDB)),
store.NewMDBXDB,
wire.Bind(new(store.KVDB), new(*store.MDBXDB)),
store.NewPebbleClockStore,
store.NewPebbleCoinStore,
store.NewPebbleKeyStore,
Expand Down
34 changes: 17 additions & 17 deletions node/app/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/consensus/data/frame_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (e *DataClockConsensusEngine) applySnapshot(
return nil
}

temporaryStore := store.NewPebbleDB(&config.DBConfig{
temporaryStore := store.NewMDBXDB(&config.DBConfig{
Path: snapshotDBPath,
})
temporaryClockStore := store.NewPebbleClockStore(temporaryStore, e.logger)
Expand Down
61 changes: 60 additions & 1 deletion node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ var (
false,
"print node related information",
)
migrate = flag.String(
"migrate",
"",
"migrate from Pebble to MDBX from specified path (e.g. /home/user/backup/.config/store)",
)
debug = flag.Bool(
"debug",
false,
Expand Down Expand Up @@ -329,7 +334,7 @@ func main() {
}

if *compactDB && *core == 0 {
db := store.NewPebbleDB(nodeConfig.DB)
db := store.NewMDBXDB(nodeConfig.DB)
if err := db.CompactAll(); err != nil {
panic(err)
}
Expand Down Expand Up @@ -375,6 +380,60 @@ func main() {
console.Run()
return
}
if *migrate != "" {
fmt.Printf("Migrating from Pebble to MDBX from %s\n", *migrate)
d, err := os.Stat(filepath.Join(*migrate, "LOCK"))
if err != nil || d == nil {
fmt.Printf("%s does not look like a pebble db! Double check your path", *migrate)
return
}
dbConfig := &config.DBConfig{
Path: *migrate,
}
pebbleInput := store.NewPebbleDB(dbConfig)
mdbxOutput := store.NewMDBXDB(nodeConfig.DB)

allIter, err := pebbleInput.NewIter(nil, nil)
if err != nil {
panic(err)
}
batch := mdbxOutput.NewBatch(false)
total := 0
for allIter.First(); allIter.Valid(); allIter.Next() {
err := batch.Set(allIter.Key(), allIter.Value())
if err != nil {
panic(err)
}
total++
if total%10_000 == 0 {
err := batch.Commit()
if err != nil {
panic(err)
}
fmt.Printf("Commit. Total: %d\n", total)
}
}
err = batch.Commit()
if err != nil {
panic(err)
}
fmt.Printf("Commit. Total: %d\n", total)
err = allIter.Close()
if err != nil {
panic(err)
}
err = pebbleInput.Close()
if err != nil {
panic(err)
}
err = mdbxOutput.Close()
if err != nil {
panic(err)
}
fmt.Println("Done.")

return
}

if *dhtOnly {
done := make(chan os.Signal, 1)
Expand Down
Loading