Skip to content

Commit 1f1fe50

Browse files
committed
move flags to their own file
1 parent 25ba1d4 commit 1f1fe50

File tree

3 files changed

+63
-57
lines changed

3 files changed

+63
-57
lines changed

cmd/crawler/api.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,6 @@ var (
2828
&dropNodesTimeFlag,
2929
},
3030
}
31-
crawlerDBFlag = cli.StringFlag{
32-
Name: "crawler-db",
33-
Usage: "Crawler SQLite file name",
34-
Required: true,
35-
}
36-
apiDBFlag = cli.StringFlag{
37-
Name: "api-db",
38-
Usage: "API SQLite file name",
39-
Required: true,
40-
}
41-
dropNodesTimeFlag = cli.DurationFlag{
42-
Name: "drop-time",
43-
Usage: "Time to drop crawled nodes without any updates",
44-
Value: 24 * time.Hour,
45-
}
4631
)
4732

4833
func startAPI(ctx *cli.Context) error {

cmd/crawler/crawlercmd.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package main
1919
import (
2020
"database/sql"
2121
"os"
22-
"time"
2322

2423
_ "modernc.org/sqlite"
2524

@@ -59,47 +58,6 @@ var (
5958
utils.SepoliaFlag,
6059
},
6160
}
62-
bootnodesFlag = cli.StringSliceFlag{
63-
Name: "bootnodes",
64-
Usage: ("Comma separated nodes used for bootstrapping. " +
65-
"Defaults to hard-coded values for the selected network"),
66-
}
67-
nodeURLFlag = cli.StringFlag{
68-
Name: "nodeURL",
69-
Usage: "URL of the node you want to connect to",
70-
// Value: "http://localhost:8545",
71-
}
72-
nodeFileFlag = cli.StringFlag{
73-
Name: "nodefile",
74-
Usage: "Path to a node file containing nodes to be crawled",
75-
}
76-
timeoutFlag = cli.DurationFlag{
77-
Name: "timeout",
78-
Usage: "Timeout for the crawling in a round",
79-
Value: 5 * time.Minute,
80-
}
81-
listenAddrFlag = cli.StringFlag{
82-
Name: "addr",
83-
Usage: "Listening address",
84-
Value: "0.0.0.0:0",
85-
}
86-
nodekeyFlag = cli.StringFlag{
87-
Name: "nodekey",
88-
Usage: "Hex-encoded node key",
89-
}
90-
nodedbFlag = cli.StringFlag{
91-
Name: "nodedb",
92-
Usage: "Nodes database location. Defaults to in memory database",
93-
}
94-
geoipdbFlag = cli.StringFlag{
95-
Name: "geoipdb",
96-
Usage: "geoip2 database location",
97-
}
98-
workersFlag = cli.Uint64Flag{
99-
Name: "workers",
100-
Usage: "Number of workers to start for updating nodes",
101-
Value: 16,
102-
}
10361
)
10462

10563
func crawlNodes(ctx *cli.Context) error {

cmd/crawler/flags.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,84 @@
11
package main
22

33
import (
4+
"time"
5+
46
"github.com/urfave/cli/v2"
57
)
68

79
var (
10+
apiDBFlag = cli.StringFlag{
11+
Name: "api-db",
12+
Usage: "API SQLite file name",
13+
Required: true,
14+
}
15+
apiListenAddrFlag = cli.StringFlag{
16+
Name: "addr",
17+
Usage: "Listening address",
18+
Value: "0.0.0.0:10000",
19+
}
820
autovacuumFlag = cli.StringFlag{
921
Name: "autovacuum",
1022
Usage: ("Sets the autovacuum value for the databases. Possible values: " +
1123
"NONE, FULL, or INCREMENTAL. " +
1224
"https://www.sqlite.org/pragma.html#pragma_auto_vacuum"),
1325
Value: "INCREMENTAL",
1426
}
27+
bootnodesFlag = cli.StringSliceFlag{
28+
Name: "bootnodes",
29+
Usage: ("Comma separated nodes used for bootstrapping. " +
30+
"Defaults to hard-coded values for the selected network"),
31+
}
1532
busyTimeoutFlag = cli.Uint64Flag{
1633
Name: "busy-timeout",
1734
Usage: ("Sets the busy_timeout value for the database in milliseconds. " +
1835
"https://www.sqlite.org/pragma.html#pragma_busy_timeout"),
1936
Value: 3000,
2037
}
38+
crawlerDBFlag = cli.StringFlag{
39+
Name: "crawler-db",
40+
Usage: "Crawler SQLite file name",
41+
Required: true,
42+
}
43+
dropNodesTimeFlag = cli.DurationFlag{
44+
Name: "drop-time",
45+
Usage: "Time to drop crawled nodes without any updates",
46+
Value: 24 * time.Hour,
47+
}
48+
geoipdbFlag = cli.StringFlag{
49+
Name: "geoipdb",
50+
Usage: "geoip2 database location",
51+
}
52+
listenAddrFlag = cli.StringFlag{
53+
Name: "addr",
54+
Usage: "Listening address",
55+
Value: "0.0.0.0:0",
56+
}
57+
nodedbFlag = cli.StringFlag{
58+
Name: "nodedb",
59+
Usage: "Nodes database location. Defaults to in memory database",
60+
}
61+
nodeFileFlag = cli.StringFlag{
62+
Name: "nodefile",
63+
Usage: "Path to a node file containing nodes to be crawled",
64+
}
65+
nodekeyFlag = cli.StringFlag{
66+
Name: "nodekey",
67+
Usage: "Hex-encoded node key",
68+
}
69+
nodeURLFlag = cli.StringFlag{
70+
Name: "nodeURL",
71+
Usage: "URL of the node you want to connect to",
72+
// Value: "http://localhost:8545",
73+
}
74+
timeoutFlag = cli.DurationFlag{
75+
Name: "timeout",
76+
Usage: "Timeout for the crawling in a round",
77+
Value: 5 * time.Minute,
78+
}
79+
workersFlag = cli.Uint64Flag{
80+
Name: "workers",
81+
Usage: "Number of workers to start for updating nodes",
82+
Value: 16,
83+
}
2184
)

0 commit comments

Comments
 (0)