2019-11-25 13:46:36 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2019-12-06 07:18:26 +00:00
|
|
|
"fmt"
|
|
|
|
|
2020-01-15 12:47:13 +00:00
|
|
|
"github.com/ledgerwatch/bolt"
|
2019-11-25 13:46:36 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/state/stateless"
|
2020-04-04 07:18:10 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
2019-11-25 13:46:36 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2020-07-27 12:15:48 +00:00
|
|
|
withPrivateApi(gasLimitsCmd)
|
2019-11-25 13:46:36 +00:00
|
|
|
rootCmd.AddCommand(gasLimitsCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
var gasLimitsCmd = &cobra.Command{
|
|
|
|
Use: "gasLimits",
|
|
|
|
Short: "gasLimits",
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2020-04-04 07:18:10 +00:00
|
|
|
ctx := cmd.Context()
|
|
|
|
|
|
|
|
localDB, err := bolt.Open(file()+"_gl", 0600, &bolt.Options{})
|
2020-01-15 12:47:13 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-03-11 11:02:37 +00:00
|
|
|
|
2020-07-27 12:15:48 +00:00
|
|
|
remoteDB, err := ethdb.NewRemote().Path(privateApiAddr).Open()
|
2019-12-06 07:18:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Processing started...")
|
2020-04-04 07:18:10 +00:00
|
|
|
stateless.NewGasLimitReporter(ctx, remoteDB, localDB).GasLimits(ctx)
|
2019-11-25 13:46:36 +00:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|