mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-01 00:31:21 +00:00
d33302c2be
* added tls auth * added client side * put --tls * fixed flag * Add key/cert generation instructions, turn off Common Name verification * Add CLI arguments and Warning * Lint * Update the doc about Internal IP Co-authored-by: Alexey Akhunov <akhounov@gmail.com>
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path"
|
|
"time"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/state/stateless"
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
stateGrowthCmd := &cobra.Command{
|
|
Use: "stateGrowth",
|
|
Short: "stateGrowth",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
ctx := cmd.Context()
|
|
|
|
localDB := ethdb.NewLMDB().Path(file() + "_sg").WithBucketsConfig(func(defaultBuckets dbutils.BucketsCfg) dbutils.BucketsCfg {
|
|
return dbutils.BucketsCfg{
|
|
stateless.MainHashesBucket: {},
|
|
stateless.ReportsProgressBucket: {},
|
|
}
|
|
}).MustOpen()
|
|
|
|
remoteDB, _, err := ethdb.NewRemote().Path(privateApiAddr).Open("", "", "")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println("Processing started...")
|
|
stateless.NewStateGrowth1Reporter(ctx, remoteDB, localDB).StateGrowth1(ctx)
|
|
stateless.NewStateGrowth2Reporter(ctx, remoteDB, localDB).StateGrowth2(ctx)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
withPrivateApi(stateGrowthCmd)
|
|
rootCmd.AddCommand(stateGrowthCmd)
|
|
}
|
|
|
|
// Generate name off the file for snapshot
|
|
// Each day has it's own partition
|
|
// It means that you can only continue execution of report from last snapshot.Save() checkpoint - read buckets forward from last key
|
|
// But not re-read bucket
|
|
func file() string {
|
|
dir := path.Join(os.TempDir(), "turbo_geth_reports")
|
|
if err := os.MkdirAll(dir, 0770); err != nil {
|
|
panic(err)
|
|
}
|
|
return path.Join(dir, time.Now().Format("2006-01-02"))
|
|
}
|