mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-24 20:47:16 +00:00
d2e5cc5cb5
* Add print_migration command to integration * Not run migrations for print commands * Reverse migration * Fix lint * Add datadir to run_migrations * Add lmdb.mapSize to integration * Make lmdb.mapSize effective * Fix * receipt sizes * fix print * Switch to another version of lmdb * Collector from existing files * Not load * Commit after clearing * Add methods for clear/drop buckets by multiple transactions * Fix to lmdb * Not remove temp files * Not load * Re-enable loading * Prints * Try to fix refill * Migration in 3 steps * tidy mod * Fix lint * Fix tests * Migrations for CBOR receipts in 3 txs * Fix lint Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package commands
|
|
|
|
import (
|
|
"github.com/c2h5oh/datasize"
|
|
"github.com/ledgerwatch/turbo-geth/cmd/utils"
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
"github.com/ledgerwatch/turbo-geth/internal/debug"
|
|
"github.com/ledgerwatch/turbo-geth/migrations"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "integration",
|
|
Short: "long and heavy integration tests for turbo-geth",
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
if err := utils.SetupCobra(cmd); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
if len(chaindata) > 0 {
|
|
db := openDatabase()
|
|
defer db.Close()
|
|
if cmd != cmdPrintMigrations && cmd != cmdPrintStages && cmd != cmdRemoveMigration {
|
|
if err := migrations.NewMigrator().Apply(db, datadir); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
}
|
|
},
|
|
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
|
defer utils.StopDebug()
|
|
},
|
|
}
|
|
|
|
func RootCommand() *cobra.Command {
|
|
utils.CobraFlags(rootCmd, append(debug.Flags, utils.MetricFlags...))
|
|
return rootCmd
|
|
}
|
|
|
|
func openDatabase() *ethdb.ObjectDatabase {
|
|
opts := ethdb.NewLMDB().Path(chaindata)
|
|
if mapSizeStr != "" {
|
|
var mapSize datasize.ByteSize
|
|
must(mapSize.UnmarshalText([]byte(mapSizeStr)))
|
|
opts = opts.MapSize(mapSize)
|
|
}
|
|
if freelistReuse > 0 {
|
|
opts = opts.MaxFreelistReuse(uint(freelistReuse))
|
|
}
|
|
return ethdb.NewObjectDatabase(opts.MustOpen())
|
|
}
|