-
Notifications
You must be signed in to change notification settings - Fork 5
/
stats.go
51 lines (38 loc) · 1.36 KB
/
stats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package flotscmd
import (
"fmt"
"github.com/benleb/gloomberg/internal/flots"
"github.com/ethereum/go-ethereum/common"
"github.com/lmittmann/w3"
"github.com/spf13/cobra"
)
// statsCmd represents the userStats command
var statsCmd = &cobra.Command{
Use: "stats",
Aliases: []string{"userStats", "bundleStats"},
Short: "gets the user stats and, if a bundle hash is provided, the bundle stats for that bundle",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("stats called")
flots := flots.New()
userStats := flots.GetUserStats()
// print user statistics
lo.Info(fmt.Sprintf("High priority: %t", userStats.IsHighPriority))
lo.Info(fmt.Sprintf("7 day fees: %s ETH", w3.FromWei(userStats.Last7dValidatorPayments, 18)))
lo.Info(fmt.Sprintf("Total fees: %s ETH", w3.FromWei(userStats.AllTimeValidatorPayments, 18)))
if flagBBundleHash == "" {
return
}
fmt.Printf("\n\n\n\n")
bundleHash := common.HexToHash(flagBBundleHash)
lo.Info(fmt.Sprintf("bundleStats | blockNum: %d | bundleHash: %s\n", flots.LatestBlock().Uint64(), bundleHash.String()))
bundleStats := flots.GetBundleStats(bundleHash)
lo.Info(fmt.Sprintf("bundleStats: %+v\n", bundleStats))
},
}
func init() {
FlotsCmd.AddCommand(statsCmd)
statsCmd.Flags().StringVarP(&flagBBundleHash, "bundleHash", "s", "", "bundleHash")
}