-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathmain.go
More file actions
105 lines (97 loc) · 2.75 KB
/
main.go
File metadata and controls
105 lines (97 loc) · 2.75 KB
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
104
105
// 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 cmd_merge //nolint:stylecheck
import (
"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 (
log *zap.SugaredLogger
numRPCWorkers = common.GetEnvInt("MERGER_RPC_WORKERS", 8)
// Helpers
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",
},
&cli.StringFlag{
Name: "clickhouse-dsn",
EnvVars: []string{"CLICKHOUSE_DSN"},
Usage: "ClickHouse server DSN (e.g. clickhouse://user:password@host:9440/dbname?secure=true or clickhouse://default:password@clickhouse:9000/default)",
Category: "Data Source: Clickhouse",
},
&cli.StringFlag{
Name: "date-from",
EnvVars: []string{"DATE_FROM"},
Usage: "Start date (inclusive) for data extraction (e.g. 2022-01-01 or 2022-01-01T00:00:00Z)",
Category: "Data Source: Clickhouse",
},
&cli.StringFlag{
Name: "date-to",
EnvVars: []string{"DATE_TO"},
Usage: "End date (exclusive) for data extraction (e.g. 2022-01-02 or 2022-01-02T00:00:00Z)",
Category: "Data Source: Clickhouse",
},
}
)
var Command = cli.Command{
Name: "merge",
Usage: "Load input CSV files, deduplicate, sort and produce single output file",
Subcommands: []*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,
},
},
}