-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmain.go
103 lines (93 loc) · 2.29 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Loads many source CSV files (produced by the collector), creates summary files in CSV and Parquet, and writes a single CSV file with all raw transactions
package main
import (
"os"
"github.com/flashbots/mempool-dumpster/common"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
var (
version = "dev" // is set during build process
debug = os.Getenv("DEBUG") == "1"
// Helpers
log *zap.SugaredLogger
printer = message.NewPrinter(language.English)
// Flags
commonFlags = []cli.Flag{
&cli.StringFlag{
Name: "out",
Value: "out/",
Usage: "output directory",
},
&cli.StringFlag{
Name: "fn-prefix",
Value: "",
Usage: "output file prefix (i.e. date)",
},
}
mergeTxFlags = []cli.Flag{
&cli.StringSliceFlag{
Name: "tx-blacklist",
Value: &cli.StringSlice{},
Usage: "blacklisted transaction input files (i.e. to ignore txs of previous day)",
},
&cli.StringSliceFlag{
Name: "sourcelog",
Value: &cli.StringSlice{},
Usage: "sourcelog files (to add sources to transactions)",
},
&cli.StringSliceFlag{ //nolint:exhaustruct
Name: "check-node",
Usage: "eth nodes for checking tx inclusion status",
},
&cli.BoolFlag{
Name: "write-tx-csv",
Value: false,
Usage: "write a CSV with all received transactions (timestamp_ms,hash,raw_tx)",
},
&cli.BoolFlag{
Name: "write-summary",
Usage: "run analyzer and write summary",
},
}
)
func check(err error, msg string) {
if err != nil {
log.Fatalw(msg, "error", err)
}
}
func main() {
log = common.GetLogger(debug, false)
defer func() { _ = log.Sync() }()
app := &cli.App{
Name: "merge",
Usage: "Load input CSV files, deduplicate, sort and produce single output file",
Commands: []*cli.Command{
{
Name: "transactions",
Aliases: []string{"tx", "t"},
Usage: "merge transaction CSVs",
Flags: append(commonFlags, mergeTxFlags...),
Action: mergeTransactions,
},
{
Name: "sourcelog",
Aliases: []string{"s"},
Usage: "merge sourcelog CSVs",
Flags: commonFlags,
Action: mergeSourcelog,
},
{
Name: "trash",
Usage: "merge trash CSVs",
Flags: commonFlags,
Action: mergeTrash,
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}