mirror of
https://github.com/luxfi/coreth.git
synced 2026-10-30 17:00:51 +00:00
- Update import from vm/rpcchainvm to vm/rpc/chain - Update vm dependency to v1.0.18 - node dependency now test-only (platformvm.NewClient for warp tests)
38 lines
905 B
Go
38 lines
905 B
Go
//go:build pebble
|
|
|
|
package evm
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/luxfi/database/manager"
|
|
"github.com/luxfi/geth/core/rawdb"
|
|
"github.com/luxfi/geth/ethdb"
|
|
)
|
|
|
|
// openSourceDatabase opens a source database for import operations
|
|
func openSourceDatabase(dataPath string) (ethdb.Database, error) {
|
|
// Open the source database using luxfi/database (pebbledb build tag).
|
|
db, err := manager.NewManager("", nil).New(&manager.Config{
|
|
Type: "pebbledb",
|
|
Path: dataPath,
|
|
ReadOnly: true,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// Wrap with rawdb for higher-level access
|
|
// The ancient data is stored in a subdirectory of the chaindata directory
|
|
ancientPath := filepath.Join(dataPath, "ancient")
|
|
sourceDB, err := rawdb.Open(ðdbAdapter{db: db}, rawdb.OpenOptions{
|
|
ReadOnly: true,
|
|
Ancient: ancientPath,
|
|
})
|
|
if err != nil {
|
|
db.Close()
|
|
return nil, err
|
|
}
|
|
return sourceDB, nil
|
|
}
|