-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathcommands.go
250 lines (245 loc) · 6.08 KB
/
commands.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package main
import cli "github.com/urfave/cli"
func getCommands() cli.Commands {
groupsDef := "[group-definition]"
return cli.Commands{
{
Name: "link",
Usage: "create a secure link to a conode",
Aliases: []string{"l"},
Subcommands: cli.Commands{
{
Name: "add",
Usage: "create a secure link to a conode",
ArgsUsage: "private.toml",
Aliases: []string{"a"},
Action: linkAdd,
},
{
Name: "del",
Usage: "remove a secure link to a conode",
ArgsUsage: "ip:port",
Aliases: []string{"d", "rm"},
Action: linkDel,
},
{
Name: "list",
Usage: "show all secure links stored in scmgr",
Aliases: []string{"ls"},
Action: linkList,
},
{
Name: "query",
Usage: "request list of secure links in conode",
ArgsUsage: "ip:port",
Aliases: []string{"q"},
Action: linkQuery,
},
},
},
{
Name: "follow",
Usage: "allow conode to be included in skipchain",
Aliases: []string{"f"},
Subcommands: cli.Commands{
{
Name: "add",
Usage: "allow inclusion of conode in skipchain",
ArgsUsage: "skipchain-id",
Aliases: []string{"a"},
Subcommands: cli.Commands{
{
Name: "single",
Usage: "only allow inclusion in this specific chain",
ArgsUsage: "skipchain-id ip:port",
Action: followAddID,
},
{
Name: "roster",
Usage: "allow inclusion of conode in new skipchains from roster of specified skipchain",
ArgsUsage: "skipchain-id ip:port",
Action: followAddRoster,
Flags: []cli.Flag{
cli.StringFlag{
Name: "lookup, l",
Usage: "IP:Port - conode that has a copy of the skipchain",
},
cli.BoolFlag{
Name: "any, a",
Usage: "Allow new chain if any of the nodes is present",
},
},
},
},
},
{
Name: "delete",
Usage: "remove authorization for inclusion in skipchain",
Aliases: []string{"del", "rm", "d"},
ArgsUsage: "skipchain-id ip:port",
Action: followDel,
},
{
Name: "list",
Usage: "list all skipchains a conode follows",
ArgsUsage: "ip:port",
Aliases: []string{"ls"},
Action: followList,
},
},
},
{
Name: "skipchain",
Usage: "work with skipchains in cothority",
Aliases: []string{"s"},
Subcommands: cli.Commands{
{
Name: "create",
Usage: "make a new skipchain",
Aliases: []string{"c"},
ArgsUsage: groupsDef,
Action: scCreate,
Flags: []cli.Flag{
cli.IntFlag{
Name: "base, b",
Value: 2,
Usage: "base for skipchains",
},
cli.IntFlag{
Name: "height, he",
Value: 2,
Usage: "maximum height of skipchain",
},
},
},
{
Name: "block",
Usage: "work on blocks of an existing skipchain",
Aliases: []string{"b"},
Subcommands: cli.Commands{
{
Name: "add",
Usage: "create a new block on the server and save it in local cache",
Aliases: []string{"a"},
ArgsUsage: "skipchain-id",
Action: scAdd,
Flags: []cli.Flag{
cli.StringFlag{
Name: "roster, r",
Value: "",
Usage: "file containing new roster",
},
cli.StringFlag{
Name: "data",
Value: "",
Usage: "data to put into the block",
},
},
},
{
Name: "print",
Usage: "show the content of a block from the local cache",
Aliases: []string{"p"},
ArgsUsage: "skipblock-id",
Action: scPrint,
},
},
},
{
Name: "updates",
Usage: "get the list of updated blocks for a chain",
Aliases: []string{"u"},
ArgsUsage: groupsDef,
Action: scUpdates,
Flags: []cli.Flag{
cli.StringFlag{
Name: "from",
Usage: "last known block hash",
},
cli.IntFlag{
Name: "level",
Value: -1,
Usage: "maximum height links to use (default: longest forward links available)",
},
cli.IntFlag{
Name: "count",
Value: -1,
Usage: "limit on how many blocks to fetch (default: all available blocks)",
},
},
},
{
Name: "optimize",
Usage: "create missing forward link to optimize the proof of a given block",
Aliases: []string{"o"},
Action: scOptimize,
Flags: []cli.Flag{
cli.StringFlag{
Name: "roster",
Usage: "conodes where to propagate",
},
cli.StringFlag{
Name: "id",
Usage: "target block or skipchain to optimize",
},
},
},
{
Name: "scan",
Usage: "get all skipchains from a node",
Action: scScan,
ArgsUsage: "URL of node",
},
},
},
{
Name: "scdns",
Usage: "skipchain dns handling for web frontend",
Aliases: []string{"d"},
Subcommands: []cli.Command{
{
Name: "fetch",
Usage: "request a skipchain and store it locally",
Aliases: []string{"f"},
ArgsUsage: groupsDef + " skipchain-id",
Action: dnsFetch,
},
{
Name: "list",
Aliases: []string{"l"},
Usage: "lists all locally stored skipchains",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "long, l",
Usage: "give long id of blocks",
},
},
Action: dnsList,
},
{
Name: "index",
Aliases: []string{"i"},
Usage: "create index-files for all known skipchains",
ArgsUsage: "output_path",
Action: dnsIndex,
},
{
Name: "update",
Aliases: []string{"u"},
Usage: "update all locally stored skipchains",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "new, n",
Usage: "fetch new skipchains from conodes",
},
cli.StringFlag{
Name: "roster, r",
Usage: "add skipchains from conodes of this roster",
},
},
Action: dnsUpdate,
},
},
},
}
}