-
Notifications
You must be signed in to change notification settings - Fork 5
/
bench.go
94 lines (90 loc) · 2.09 KB
/
bench.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
package main
import (
"fmt"
"os"
"strconv"
"github.com/smartbch/moeingads/datatree"
)
func printUsage() {
fmt.Printf("Usage: %s genacc <number-of-accounts>\n", os.Args[0])
fmt.Printf("Usage: %s checkacc <number-of-accounts>\n", os.Args[0])
fmt.Printf("Usage: %s gentx <number-of-accounts> <number-of-blocks>\n", os.Args[0])
fmt.Printf("Usage: %s runtx <number-of-blocks>\n", os.Args[0])
}
func main() {
if datatree.BufferSize < 512*1024 {
panic("BufferSize too small")
}
if len(os.Args) < 3 {
printUsage()
return
}
if os.Args[1] != "genacc" && os.Args[1] != "checkacc" && os.Args[1] != "gentx" && os.Args[1] != "runtx" {
fmt.Printf("Invalid sub-command: %s\n", os.Args[1])
printUsage()
return
}
if os.Args[1] == "genacc" {
if len(os.Args) != 3 {
printUsage()
return
}
randFilename := os.Getenv("RANDFILE")
if len(randFilename) == 0 {
fmt.Printf("No RANDFILE specified. Exiting...\n")
return
}
numAccounts, err := strconv.Atoi(os.Args[2])
if err != nil {
panic(err)
}
RunGenerateAccounts(numAccounts, randFilename, "shortkey.json")
}
if os.Args[1] == "checkacc" {
if len(os.Args) != 3 {
printUsage()
return
}
randFilename := os.Getenv("RANDFILE")
if len(randFilename) == 0 {
fmt.Printf("No RANDFILE specified. Exiting...")
return
}
numAccounts, err := strconv.Atoi(os.Args[2])
if err != nil {
panic(err)
}
RunCheckAccounts(numAccounts, randFilename)
}
if os.Args[1] == "gentx" {
if len(os.Args) != 4 {
printUsage()
return
}
randFilename := os.Getenv("RANDFILE")
if len(randFilename) == 0 {
fmt.Printf("No RANDFILE specified. Exiting...")
return
}
numAccounts, err := strconv.Atoi(os.Args[2])
if err != nil {
panic(err)
}
numBlock, err := strconv.Atoi(os.Args[3])
if err != nil {
panic(err)
}
RunGenerateTxFile(numBlock*NumEpochInBlock, uint64(numAccounts), "shortkey.json", randFilename, "tx.dat")
}
if os.Args[1] == "runtx" {
if len(os.Args) != 3 {
printUsage()
return
}
numBlock, err := strconv.Atoi(os.Args[2])
if err != nil {
panic(err)
}
RunTx(numBlock, "tx.dat")
}
}