github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/cmd/tendermint/commands/snapshot.go (about)

     1  package commands
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"github.com/ari-anchor/sei-tendermint/config"
     7  	"github.com/ari-anchor/sei-tendermint/internal/dbsync"
     8  	"github.com/spf13/cobra"
     9  )
    10  
    11  func MakeSnapshotCommand(confGetter func(*cobra.Command) (*config.Config, error)) *cobra.Command {
    12  	return &cobra.Command{
    13  		Use:   "snapshot [height]",
    14  		Short: "Take DBSync snapshot for given height",
    15  		RunE: func(cmd *cobra.Command, args []string) error {
    16  			conf, err := confGetter(cmd)
    17  			if err != nil {
    18  				return err
    19  			}
    20  			height, err := strconv.ParseUint(args[0], 10, 64)
    21  			if err != nil {
    22  				return err
    23  			}
    24  			return dbsync.Snapshot(height, *conf.DBSync, conf.BaseConfig)
    25  		},
    26  	}
    27  }