-
Notifications
You must be signed in to change notification settings - Fork 6
/
flags.go
327 lines (281 loc) · 6.84 KB
/
flags.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
/**
* @file
* @copyright defined in scdo/LICENSE
*/
package cmd
import (
"fmt"
"github.com/scdoproject/go-scdo/common"
"github.com/urfave/cli"
)
type rpcFlag interface {
getValue() (interface{}, error)
}
type scdoAddressFlag struct {
cli.StringFlag
}
func (flag scdoAddressFlag) getValue() (interface{}, error) {
if val := *flag.Destination; len(val) > 0 {
return common.HexToAddress(val)
}
return common.EmptyAddress, nil
}
type abiFlag struct {
cli.StringFlag
}
func (flag abiFlag) getValue() (interface{}, error) {
if val := *flag.Destination; len(val) > 0 {
abiJSON, err := readABIFile(val)
if err != nil {
return "", fmt.Errorf("failed to read abi file, err: %s", err)
}
return abiJSON, nil
}
return "", nil
}
var (
truestAddressValue string
trustAddressFlag = cli.StringFlag{
Name: "trust, t",
Value: "",
Usage: "node, for example: -t address:port",
Destination: &truestAddressValue,
}
addressValue string
addressFlag = cli.StringFlag{
Name: "address, a",
Value: "127.0.0.1:8027",
Usage: "address for client to request",
Destination: &addressValue,
}
accountValue string
accountFlag = scdoAddressFlag{
StringFlag: cli.StringFlag{
Name: "account",
Value: "",
Usage: "account address",
Destination: &accountValue,
},
}
heightValue int64
heightFlag = cli.Int64Flag{
Name: "height",
Value: -1,
Usage: "block height or current block height for negative value",
Destination: &heightValue,
}
heightPosValue uint64
heightPosFlag = cli.Uint64Flag{
Name: "height",
Value: 0,
Usage: "block height, default value is zero",
Destination: &heightPosValue,
}
trialValue string
trialFlag = cli.StringFlag{
Name: "trial, t",
Value: "false",
Usage: "trial for transanction or contract, value of false is to send tx or contract, and true is to call",
Destination: &trialValue,
}
fulltxValue bool
fulltxFlag = cli.BoolFlag{
Name: "fulltx, f",
Usage: "whether print full transaction info",
Destination: &fulltxValue,
}
hashValue string
hashFlag = cli.StringFlag{
Name: "hash",
Usage: "hash value in hex",
Destination: &hashValue,
}
fromValue string
fromFlag = cli.StringFlag{
Name: "from",
Usage: "key file of the sender",
Destination: &fromValue,
}
toValue string
toFlag = cli.StringFlag{
Name: "to",
Usage: "to address",
Destination: &toValue,
}
amountValue string
amountFlag = cli.StringFlag{
Name: "amount",
Usage: "amount value, unit is wen",
Destination: &amountValue,
}
payloadValue string
payloadFlag = cli.StringFlag{
Name: "payload",
Value: "",
Usage: "transaction payload info",
Destination: &payloadValue,
}
priceValue string
priceFlag = cli.StringFlag{
Name: "price",
Value: "10",
Usage: "transaction gas price in Wen",
Destination: &priceValue,
}
gasLimitValue uint64
gasLimitFlag = cli.Uint64Flag{
Name: "gas",
Value: 200000,
Usage: "maximum gas for transaction",
Destination: &gasLimitValue,
}
nonceValue uint64
nonceFlag = cli.Uint64Flag{
Name: "nonce",
Value: 0,
Usage: "transaction nonce",
Destination: &nonceValue,
}
contractValue string
contractFlag = scdoAddressFlag{
StringFlag: cli.StringFlag{
Name: "contract",
Usage: "contract code in hex",
Destination: &contractValue,
},
}
topicValue string
topicFlag = cli.StringFlag{
Name: "topic",
Usage: "topic",
Destination: &topicValue,
}
threadsValue uint
threadsFlag = cli.UintFlag{
Name: "threads",
Usage: "miner threads",
Destination: &threadsValue,
}
coinbaseValue string
coinbaseFlag = cli.StringFlag{
Name: "coinbase",
Usage: "miner coinbase in hex",
Destination: &coinbaseValue,
}
miningNonceValue uint64
miningNonceFlag = cli.Uint64Flag{
Name: "nonce",
Usage: "mining nonce",
Destination: &miningNonceValue,
}
indexValue uint
indexFlag = cli.UintFlag{
Name: "index",
Usage: "transaction index, start with 0",
Value: 0,
Destination: &indexValue,
}
privateKeyValue string
privateKeyFlag = cli.StringFlag{
Name: "privatekey",
Usage: "private key for account",
Destination: &privateKeyValue,
}
fileNameValue string
fileNameFlag = cli.StringFlag{
Name: "file",
Usage: "key store file name",
Destination: &fileNameValue,
}
shardValue uint
shardFlag = cli.UintFlag{
Name: "shard",
Value: 1,
Usage: "shard number",
Destination: &shardValue,
}
gcBeforeDump bool
gcBeforeDumpFlag = cli.BoolFlag{
Name: "gc",
Usage: "GC before heap dump, default false",
Destination: &gcBeforeDump,
}
dumpFileValue string
dumpFileFlag = cli.StringFlag{
Name: "file",
Value: "heap.dump",
Usage: "heap dump file name, default heap.dump",
Destination: &dumpFileValue,
}
timeLockValue int64
timeLockFlag = cli.Int64Flag{
Name: "time",
Usage: "time lock in the HTLC",
Destination: &timeLockValue,
}
preimageValue string
preimageFlag = cli.StringFlag{
Name: "preimage",
Usage: "preimage of hash in the HTLC",
Destination: &preimageValue,
}
nameValue string
nameFlag = cli.StringFlag{
Name: "name",
Usage: "domain or subchain name",
Destination: &nameValue,
}
subChainJSONFileVale string
subChainJSONFileFlag = cli.StringFlag{
Name: "file",
Usage: "subchain json file path",
Destination: &subChainJSONFileVale,
}
outPutValue string
outPutFlag = cli.StringFlag{
Name: "output,o",
Usage: "subchain config file path",
Destination: &outPutValue,
}
staticNodesValue cli.StringSlice
staticNodesFlag = cli.StringSliceFlag{
Name: "node, n",
Usage: "subchain static node, for example:-n address:port -n address:prot",
Value: &staticNodesValue,
}
algorithmValue string
algorithmFlag = cli.StringFlag{
Name: "algorithm",
Usage: "miner algorithm",
Value: "sha256",
Destination: &algorithmValue,
}
)
// GeneratePayload
var (
abiFile string
abiFileFlag = abiFlag{
StringFlag: cli.StringFlag{
Name: "abi",
Usage: "the abi file of contract",
Destination: &abiFile,
},
}
methodName string
methodNameFlag = cli.StringFlag{
Name: "method",
Usage: "the method name of contract",
Destination: &methodName,
}
eventName string
eventNameFlag = cli.StringFlag{
Name: "event",
Usage: "the event name of contract",
Destination: &eventName,
}
// args []interface{}
argsFlag = cli.StringSliceFlag{
Name: "args",
Usage: "the parameters of contract method",
}
)