Browse Source

splitted the declaration into packages

master
Loki Verloren 3 months ago
parent
commit
45373077be
100 changed files with 607 additions and 533 deletions
  1. 25
    0
      pkg/app/conf/gen.go
  2. 40
    0
      pkg/app/create/gen.go
  3. 0
    0
      pkg/app/ctl/config.go
  4. 43
    0
      pkg/app/ctl/gen.go
  5. 0
    0
      pkg/app/ctl/httpclient.go
  6. 0
    0
      pkg/app/ctl/main.go
  7. 0
    0
      pkg/app/ctl/version.go
  8. 2
    6
      pkg/app/def/App.go
  9. 29
    170
      pkg/app/definition.go
  10. 2
    2
      pkg/app/g/generators.go
  11. 25
    0
      pkg/app/genca/gen.go
  12. 26
    0
      pkg/app/gencert/gen.go
  13. 22
    0
      pkg/app/gui/gen.go
  14. 0
    355
      pkg/app/handlers.go
  15. 140
    0
      pkg/app/help/gen.go
  16. 31
    0
      pkg/app/list/gen.go
  17. 22
    0
      pkg/app/mine/gen.go
  18. 41
    0
      pkg/app/node/gen.go
  19. 12
    0
      pkg/app/param/gen.go
  20. 40
    0
      pkg/app/shell/gen.go
  21. 68
    0
      pkg/app/test/gen.go
  22. 39
    0
      pkg/app/wallet/gen.go
  23. 0
    0
      pkg/chain/README.md
  24. 0
    0
      pkg/chain/accept.go
  25. 0
    0
      pkg/chain/bench_test.go
  26. 0
    0
      pkg/chain/blockindex.go
  27. 0
    0
      pkg/chain/chain.go
  28. 0
    0
      pkg/chain/chain_test.go
  29. 0
    0
      pkg/chain/chainio.go
  30. 0
    0
      pkg/chain/chainio_test.go
  31. 0
    0
      pkg/chain/chainview.go
  32. 0
    0
      pkg/chain/chainview_test.go
  33. 0
    0
      pkg/chain/checkpoints.go
  34. 0
    0
      pkg/chain/common_test.go
  35. 0
    0
      pkg/chain/compress.go
  36. 0
    0
      pkg/chain/compress_test.go
  37. 0
    0
      pkg/chain/config/README.md
  38. 0
    0
      pkg/chain/config/doc.go
  39. 0
    0
      pkg/chain/config/genesis.go
  40. 0
    0
      pkg/chain/config/genesis_test.go
  41. 0
    0
      pkg/chain/config/params-defs.go
  42. 0
    0
      pkg/chain/config/params-mainnet.go
  43. 0
    0
      pkg/chain/config/params-regtest.go
  44. 0
    0
      pkg/chain/config/params-simnet.go
  45. 0
    0
      pkg/chain/config/params-testnet.go
  46. 0
    0
      pkg/chain/config/params.go
  47. 0
    0
      pkg/chain/config/params/params.go
  48. 0
    0
      pkg/chain/config/params_test.go
  49. 0
    0
      pkg/chain/config/register_test.go
  50. 0
    0
      pkg/chain/config/util.go
  51. 0
    0
      pkg/chain/difficulty.go
  52. 0
    0
      pkg/chain/difficulty_test.go
  53. 0
    0
      pkg/chain/doc.go
  54. 0
    0
      pkg/chain/error.go
  55. 0
    0
      pkg/chain/error_test.go
  56. 0
    0
      pkg/chain/example_test.go
  57. 0
    0
      pkg/chain/fork/bench/bench.go
  58. 0
    0
      pkg/chain/fork/bits.go
  59. 0
    0
      pkg/chain/fork/expdecay.go
  60. 0
    0
      pkg/chain/fork/fork.go
  61. 0
    0
      pkg/chain/fork/hash.go
  62. 0
    0
      pkg/chain/fullblocktests/fullblocks_test.go
  63. 0
    0
      pkg/chain/hash/README.md
  64. 0
    0
      pkg/chain/hash/doc.go
  65. 0
    0
      pkg/chain/hash/hash.go
  66. 0
    0
      pkg/chain/hash/hash_test.go
  67. 0
    0
      pkg/chain/hash/hashfuncs.go
  68. 0
    0
      pkg/chain/hash/hashfuncs_test.go
  69. 0
    0
      pkg/chain/index/README.md
  70. 0
    0
      pkg/chain/index/addrindex.go
  71. 0
    0
      pkg/chain/index/addrindex_test.go
  72. 0
    0
      pkg/chain/index/blocklogger.go
  73. 0
    0
      pkg/chain/index/cfindex.go
  74. 0
    0
      pkg/chain/index/common.go
  75. 0
    0
      pkg/chain/index/log.go
  76. 0
    0
      pkg/chain/index/manager.go
  77. 0
    0
      pkg/chain/index/txindex.go
  78. 0
    0
      pkg/chain/log.go
  79. 0
    0
      pkg/chain/mediantime.go
  80. 0
    0
      pkg/chain/mediantime_test.go
  81. 0
    0
      pkg/chain/merkle.go
  82. 0
    0
      pkg/chain/merkle_test.go
  83. 0
    0
      pkg/chain/mining/README.md
  84. 0
    0
      pkg/chain/mining/cpu/README.md
  85. 0
    0
      pkg/chain/mining/cpu/cpuminer.go
  86. 0
    0
      pkg/chain/mining/cpu/log.go
  87. 0
    0
      pkg/chain/mining/dispatch/README.md
  88. 0
    0
      pkg/chain/mining/dispatch/cmd/client/client.go
  89. 0
    0
      pkg/chain/mining/dispatch/cmd/server/server.go
  90. 0
    0
      pkg/chain/mining/dispatch/controller.go
  91. 0
    0
      pkg/chain/mining/dispatch/controller_test.go
  92. 0
    0
      pkg/chain/mining/dispatch/kopach.go
  93. 0
    0
      pkg/chain/mining/dispatch/log.go
  94. 0
    0
      pkg/chain/mining/log.go
  95. 0
    0
      pkg/chain/mining/mining.go
  96. 0
    0
      pkg/chain/mining/mining_test.go
  97. 0
    0
      pkg/chain/mining/policy.go
  98. 0
    0
      pkg/chain/mining/policy_test.go
  99. 0
    0
      pkg/chain/notifications.go
  100. 0
    0
      pkg/chain/notifications_test.go

+ 25
- 0
pkg/app/conf/gen.go View File

@@ -0,0 +1,25 @@
1
+package conf
2
+
3
+import (
4
+	"git.parallelcoin.io/dev/9/pkg/app/def"
5
+	"git.parallelcoin.io/dev/9/pkg/app/g"
6
+)
7
+
8
+var Gen = g.Cmd("conf",
9
+	g.Pattern("^(C|conf)$"),
10
+	g.Short("run interactive configuration CLI"),
11
+	g.Detail(
12
+		"<datadir>\tsets the data directory to read and write to",
13
+	),
14
+	g.Opts("datadir"),
15
+	g.Precs("help"),
16
+	g.Handler(
17
+		func(app *def.App) int {
18
+			var r int
19
+			for r = 2; r == 2; {
20
+				r = Run(app)
21
+			}
22
+			return r
23
+		},
24
+	),
25
+)

+ 40
- 0
pkg/app/create/gen.go View File

@@ -0,0 +1,40 @@
1
+package create
2
+
3
+import (
4
+	"fmt"
5
+	"path/filepath"
6
+
7
+	"git.parallelcoin.io/dev/9/pkg/app/def"
8
+	"git.parallelcoin.io/dev/9/pkg/app/g"
9
+	"git.parallelcoin.io/dev/9/pkg/util"
10
+	walletmain "git.parallelcoin.io/dev/9/pkg/wallet/main"
11
+)
12
+
13
+var Gen = g.Cmd("create",
14
+	g.Pattern("^(cr|create)$"),
15
+	g.Short("runs the create new wallet prompt"),
16
+	g.Detail(
17
+		"<datadir>\tsets the data directory where the wallet will",
18
+		"\tbe stored",
19
+	),
20
+	g.Opts("datadir"),
21
+	g.Precs("wallet", "shell", "help"),
22
+	g.Handler(
23
+		func(app *def.App) int {
24
+			netDir := walletmain.NetworkDir(
25
+				filepath.Join(*app.Config.DataDir, "wallet"),
26
+				app.Config.ActiveNetParams.Params)
27
+			wdb := netDir // + "/wallet.db"
28
+			if exists, _ := util.FileExists(wdb); !exists {
29
+				if e := walletmain.CreateWallet(
30
+					app.Config, app.Config.ActiveNetParams, wdb); e != nil {
31
+					panic("could not create wallet " + e.Error())
32
+				}
33
+			} else {
34
+				fmt.Println("wallet already exists in", wdb+"/wallet.db", "refusing to overwrite")
35
+				return 1
36
+			}
37
+			return 0
38
+		},
39
+	),
40
+)

+ 0
- 0
pkg/app/ctl/config.go View File


+ 43
- 0
pkg/app/ctl/gen.go View File

@@ -0,0 +1,43 @@
1
+package ctl
2
+
3
+import (
4
+	"git.parallelcoin.io/dev/9/pkg/app/def"
5
+	"git.parallelcoin.io/dev/9/pkg/app/g"
6
+	"git.parallelcoin.io/dev/9/pkg/util/cl"
7
+)
8
+
9
+var Gen = g.Cmd("ctl",
10
+	g.Pattern("^(c|ctl|control)$"),
11
+	g.Short("sends rpc requests and prints the results"),
12
+	g.Detail(
13
+		"Note that all items appearing after the keyword above",
14
+		"are order-sensitive and become the RPC invocation:",
15
+		"",
16
+		"\t9 ctl help",
17
+		"",
18
+		"will print the help information returned from the RPC server,",
19
+		"and to specify the use of a wallet RPC endpoint, this must",
20
+		"precede the ctl keyword",
21
+		"",
22
+		"<datadir>\tsets the data directory to read configurations from",
23
+		"<node>\t\tindicates we are connecting to a full node RPC",
24
+		"\t\t(overrides wallet and is default)",
25
+		"<wallet>\tindicates we are connecting to a wallet RPC",
26
+	),
27
+	g.Opts("datadir", "node", "wallet", "word", "integer", "float"),
28
+	g.Precs("list"),
29
+	g.Handler(
30
+		func(app *def.App) int {
31
+			cl.Register.SetAllLevels(*app.Config.LogLevel)
32
+			g.SetAppDataDir(app, "ctl")
33
+			if j := g.ValidateProxyListeners(app); j != 0 {
34
+				return j
35
+			}
36
+			if _, ok := app.Tokens["wallet"]; ok {
37
+				*app.Config.Wallet = true
38
+			}
39
+			Main(app)
40
+			return 0
41
+		},
42
+	),
43
+)

+ 0
- 0
pkg/app/ctl/httpclient.go View File


+ 0
- 0
pkg/app/ctl/main.go View File


+ 0
- 0
pkg/app/ctl/version.go View File


+ 2
- 6
pkg/app/def/App.go View File

@@ -40,11 +40,6 @@ type AppGenerator func(ctx *App)
40 40
 // AppGenerators is a collection of AppGenerators
41 41
 type AppGenerators []AppGenerator
42 42
 
43
-// ComposeApp runs further AppGenerators on an existing App
44
-func ComposeApp(a *App, gens []AppGenerator) {
45
-	AppGenerators(gens).RunAll(a)
46
-}
47
-
48 43
 // SaveConfig writes all the data in Cats the config file at the root of DataDir
49 44
 func (r *App) SaveConfig() {
50 45
 	if r == nil {
@@ -133,8 +128,9 @@ func (r *App) UnmarshalJSON(data []byte) error {
133 128
 }
134 129
 
135 130
 // RunAll triggers AppGenerators to configure an App
136
-func (r AppGenerators) RunAll(app *App) {
131
+func (r AppGenerators) RunAll(app *App) (x AppGenerators) {
137 132
 	for _, x := range r {
138 133
 		x(app)
139 134
 	}
135
+	return
140 136
 }

+ 29
- 170
pkg/app/definition.go View File

@@ -1,187 +1,46 @@
1 1
 package app
2 2
 
3 3
 import (
4
+	"git.parallelcoin.io/dev/9/pkg/app/conf"
5
+	"git.parallelcoin.io/dev/9/pkg/app/create"
6
+	"git.parallelcoin.io/dev/9/pkg/app/ctl"
4 7
 	"git.parallelcoin.io/dev/9/pkg/app/def"
5 8
 	"git.parallelcoin.io/dev/9/pkg/app/g"
9
+	"git.parallelcoin.io/dev/9/pkg/app/genca"
10
+	"git.parallelcoin.io/dev/9/pkg/app/gencert"
11
+	"git.parallelcoin.io/dev/9/pkg/app/gui"
12
+	"git.parallelcoin.io/dev/9/pkg/app/help"
13
+	"git.parallelcoin.io/dev/9/pkg/app/list"
14
+	"git.parallelcoin.io/dev/9/pkg/app/mine"
15
+	"git.parallelcoin.io/dev/9/pkg/app/node"
6 16
 	"git.parallelcoin.io/dev/9/pkg/app/param"
17
+	"git.parallelcoin.io/dev/9/pkg/app/shell"
7 18
 	"git.parallelcoin.io/dev/9/pkg/app/state"
19
+	"git.parallelcoin.io/dev/9/pkg/app/test"
20
+	"git.parallelcoin.io/dev/9/pkg/app/wallet"
8 21
 )
9 22
 
10 23
 func Nine() (a9 *def.App) {
11
-	a9 = g.NewApp("9",
24
+	return g.NewApp("9", append(append(
12 25
 		[]def.AppGenerator{
13 26
 			g.Version("v0.9.0"),
14 27
 			g.Tagline("all in one everything for parallelcoin"),
15 28
 			g.About("full node, wallet, combined shell, RPC client for the parallelcoin blockchain"),
16
-			g.DefaultRunner(Help),
17
-			g.Cmd("help",
18
-				g.Pattern("^(h|help)$"),
19
-				g.Short("show help text and quit"),
20
-				g.Detail(
21
-					"any other command also mentioned with help",
22
-					"will have its detailed help information printed",
23
-				),
24
-				g.Precs("help"),
25
-				g.Handler(Help),
26
-			),
27
-			g.Cmd("conf",
28
-				g.Pattern("^(C|conf)$"),
29
-				g.Short("run interactive configuration CLI"),
30
-				g.Detail(
31
-					"<datadir>\tsets the data directory to read and write to",
32
-				),
33
-				g.Opts("datadir"),
34
-				g.Precs("help"),
35
-				g.Handler(Conf),
36
-			),
37
-			g.Cmd("list",
38
-				g.Pattern("^(l|list|listcommands)$"),
39
-				g.Short("lists commands available at the RPC endpoint"),
40
-				g.Detail("<datadir>\tis the enabled data directory",
41
-					"<ctl>\t\tmust be present to invoke list",
42
-					"<wallet>\tindicates to connect to the wallet RPC",
43
-					"<node>\t\t(or wallet not specified) connect to full node RPC",
44
-				),
45
-				g.Opts("datadir", "ctl", "wallet", "node"),
46
-				g.Precs("help"),
47
-				g.Handler(List),
48
-			),
49
-			g.Cmd("ctl",
50
-				g.Pattern("^(c|ctl|control)$"),
51
-				g.Short("sends rpc requests and prints the results"),
52
-				g.Detail(
53
-					"Note that all items appearing after the keyword above",
54
-					"are order-sensitive and become the RPC invocation:",
55
-					"",
56
-					"\t9 ctl help",
57
-					"",
58
-					"will print the help information returned from the RPC server,",
59
-					"and to specify the use of a wallet RPC endpoint, this must",
60
-					"precede the ctl keyword",
61
-					"",
62
-					"<datadir>\tsets the data directory to read configurations from",
63
-					"<node>\t\tindicates we are connecting to a full node RPC",
64
-					"\t\t(overrides wallet and is default)",
65
-					"<wallet>\tindicates we are connecting to a wallet RPC",
66
-				),
67
-				g.Opts("datadir", "node", "wallet", "word", "integer", "float"),
68
-				g.Precs("list"),
69
-				g.Handler(Ctl),
70
-			),
71
-			g.Cmd("node",
72
-				g.Pattern("^(n|node)$"),
73
-				g.Short("runs a full node"),
74
-				g.Detail(
75
-					"<datadir>\tsets the data directory to read configuration",
76
-					"\t\tand store data",
77
-				),
78
-				g.Opts("datadir"),
79
-				g.Precs("help", "ctl", "list"),
80
-				g.Handler(Node),
81
-			),
82
-			g.Cmd("wallet",
83
-				g.Pattern("^(w|wallet)$"),
84
-				g.Short("runs a wallet server"),
85
-				g.Detail(
86
-					"<datadir>\tsets the data directory to read configuration and", "\t\tstore data",
87
-					"<create>\truns the wallet create prompt",
88
-				),
89
-				g.Opts("datadir", "create"),
90
-				g.Precs("help", "ctl", "list"),
91
-				g.Handler(Wallet),
92
-			),
93
-			g.Cmd("shell",
94
-				g.Pattern("^(s|shell)$"),
95
-				g.Short("runs a combined node/wallet server"),
96
-				g.Detail(
97
-					"<datadir>\tsets the data directory to read configuration and", "\t\tdata",
98
-				),
99
-				g.Opts("datadir", "create"),
100
-				g.Precs("help"),
101
-				g.Handler(Shell),
102
-			),
103
-			g.Cmd("mine",
104
-				g.Pattern("^(m|mine)$"),
105
-				g.Short("run the standalone miner"),
106
-				g.Detail("runs a standalone miner to dig for parallelcoins"),
107
-				g.Opts("datadir"),
108
-				g.Precs("help"),
109
-				g.Handler(Mine),
110
-			),
111
-			g.Cmd("gui",
112
-				g.Pattern("(^g|gui)$"),
113
-				g.Short("run the GUI wallet"),
114
-				g.Detail("runs the shell and launches a native GUI interface"),
115
-				g.Opts("datadir"),
116
-				g.Precs("help"),
117
-				g.Handler(GUI),
118
-			),
119
-			g.Cmd("test",
120
-				g.Pattern("^(t|test)$"),
121
-				g.Short("run multiple full nodes"),
122
-				g.Detail(
123
-					"<datadir>\tindicates the basename to search for as the",
124
-					"\t\tpath to the test configurations",
125
-					"<log>\t\tindicates to write logs to the individual data",
126
-					"\t\tdirectories instead of print to stdout",
127
-					"<integer>\tindicates how many nodes to create (minimum 2)",
128
-					"",
129
-					"Note that the configured wallet and node ports will be",
130
-					"the only ports listening for testing RPC and transactions.",
131
-				),
132
-				g.Opts("datadir", "log", "integer"),
133
-				g.Precs("help"),
134
-				g.Handler(TestHandler),
135
-			),
136
-			g.Cmd("create",
137
-				g.Pattern("^(cr|create)$"),
138
-				g.Short("runs the create new wallet prompt"),
139
-				g.Detail(
140
-					"<datadir>\tsets the data directory where the wallet will",
141
-					"\tbe stored",
142
-				),
143
-				g.Opts("datadir"),
144
-				g.Precs("wallet", "shell", "help"),
145
-				g.Handler(Create),
146
-			),
147
-			g.Cmd("gencert",
148
-				g.Pattern("^(gencert)$"),
149
-				g.Short("generate a number of TLS key pairs for nodes"),
150
-				g.Detail(
151
-					"<word>\tsets the name of the CA signing key file to use",
152
-					"<integer>\tsets the number of keys to generate",
153
-					"\t\t(append a number to the filename)",
154
-				),
155
-				g.Opts("word", "integer"),
156
-				g.Precs("help"),
157
-				g.Handler(GenCerts),
158
-			),
159
-			g.Cmd("genca",
160
-				g.Pattern("^genca$"),
161
-				g.Short("generate TLS certification authority key pair"),
162
-				g.Detail(
163
-					"<word>\tsets the name of the CA signing key file to",
164
-					"\t\toutput",
165
-				),
166
-				g.Opts("word"),
167
-				g.Precs("help"),
168
-				g.Handler(GenCA),
169
-			),
170
-			g.Cmd("log",
171
-				g.Pattern("^(L|log)$"),
172
-				g.Short(
173
-					"write to log in <datadir> file instead of printing to console",
174
-				),
175
-				g.Detail(
176
-					"<datadir>\tsets the data directory where the wallet will",
177
-					"\t\tbe stored",
178
-				),
179
-				g.Opts(),
180
-				g.Precs("help", "node", "wallet", "shell", "test"),
181
-			),
29
+			conf.Gen,
30
+			create.Gen,
31
+			ctl.Gen,
32
+			genca.Gen,
33
+			gencert.Gen,
34
+			gui.Gen,
35
+			help.Gen,
36
+			list.Gen,
37
+			mine.Gen,
38
+			node.Gen,
39
+			shell.Gen,
40
+			test.Gen,
41
+			wallet.Gen,
182 42
 		},
43
+		param.Gen...),
44
+		state.Gen...),
183 45
 	)
184
-	def.ComposeApp(a9, param.Gen)
185
-	def.ComposeApp(a9, state.Gen)
186
-	return
187 46
 }

+ 2
- 2
pkg/app/g/generators.go View File

@@ -36,8 +36,8 @@ func NewApp(name string, g []def.AppGenerator) (out *def.App) {
36 36
 	gen := def.AppGenerators(g)
37 37
 	out = &def.App{
38 38
 		Name:     name,
39
-		Cats:     def.Cats{},
40
-		Commands: def.Commands{},
39
+		Cats:     make(def.Cats),
40
+		Commands: make(def.Commands),
41 41
 		StateCfg: &nine.StateConfig{},
42 42
 	}
43 43
 	gen.RunAll(out)

+ 25
- 0
pkg/app/genca/gen.go View File

@@ -0,0 +1,25 @@
1
+package genca
2
+
3
+import (
4
+	"fmt"
5
+
6
+	"git.parallelcoin.io/dev/9/pkg/app/def"
7
+	"git.parallelcoin.io/dev/9/pkg/app/g"
8
+)
9
+
10
+var Gen = g.Cmd("genca",
11
+	g.Pattern("^genca$"),
12
+	g.Short("generate TLS certification authority key pair"),
13
+	g.Detail(
14
+		"<word>\tsets the name of the CA signing key file to",
15
+		"\t\toutput",
16
+	),
17
+	g.Opts("word"),
18
+	g.Precs("help"),
19
+	g.Handler(
20
+		func(app *def.App) int {
21
+			fmt.Println("Sorry, not implemented yet")
22
+			return 0
23
+		},
24
+	),
25
+)

+ 26
- 0
pkg/app/gencert/gen.go View File

@@ -0,0 +1,26 @@
1
+package gencert
2
+
3
+import (
4
+	"fmt"
5
+
6
+	"git.parallelcoin.io/dev/9/pkg/app/def"
7
+	"git.parallelcoin.io/dev/9/pkg/app/g"
8
+)
9
+
10
+var Gen = g.Cmd("gencert",
11
+	g.Pattern("^(gencert)$"),
12
+	g.Short("generate a number of TLS key pairs for nodes"),
13
+	g.Detail(
14
+		"<word>\tsets the name of the CA signing key file to use",
15
+		"<integer>\tsets the number of keys to generate",
16
+		"\t\t(append a number to the filename)",
17
+	),
18
+	g.Opts("word", "integer"),
19
+	g.Precs("help"),
20
+	g.Handler(
21
+		func(app *def.App) int {
22
+			fmt.Println("Sorry, not implemented yet")
23
+			return 0
24
+		},
25
+	),
26
+)

+ 22
- 0
pkg/app/gui/gen.go View File

@@ -0,0 +1,22 @@
1
+package gui
2
+
3
+import (
4
+	"fmt"
5
+
6
+	"git.parallelcoin.io/dev/9/pkg/app/def"
7
+	"git.parallelcoin.io/dev/9/pkg/app/g"
8
+)
9
+
10
+var Gen = g.Cmd("gui",
11
+	g.Pattern("(^g|gui)$"),
12
+	g.Short("run the GUI wallet"),
13
+	g.Detail("runs the shell and launches a native GUI interface"),
14
+	g.Opts("datadir"),
15
+	g.Precs("help"),
16
+	g.Handler(
17
+		func(app *def.App) int {
18
+			fmt.Println("Sorry, not implemented yet")
19
+			return 0
20
+		},
21
+	),
22
+)

+ 0
- 355
pkg/app/handlers.go View File

@@ -1,355 +0,0 @@
1
-package app
2
-
3
-import (
4
-	"fmt"
5
-	"net"
6
-	"path/filepath"
7
-	"sort"
8
-	"strconv"
9
-
10
-	"git.parallelcoin.io/dev/9/pkg/app/conf"
11
-	"git.parallelcoin.io/dev/9/pkg/app/ctl"
12
-	"git.parallelcoin.io/dev/9/pkg/app/def"
13
-	"git.parallelcoin.io/dev/9/pkg/app/g"
14
-	"git.parallelcoin.io/dev/9/pkg/app/ll"
15
-	"git.parallelcoin.io/dev/9/pkg/app/makeconf"
16
-	"git.parallelcoin.io/dev/9/pkg/node"
17
-	"git.parallelcoin.io/dev/9/pkg/util"
18
-	"git.parallelcoin.io/dev/9/pkg/util/cl"
19
-	"git.parallelcoin.io/dev/9/pkg/util/help"
20
-	walletmain "git.parallelcoin.io/dev/9/pkg/wallet/main"
21
-)
22
-
23
-// Log is the logger for node
24
-var Log = cl.NewSubSystem("cmd/config", ll.DEFAULT)
25
-var log = Log.Ch
26
-
27
-func optTagList(s []string) (ss string) {
28
-	if len(ss) > 1 {
29
-		ss = "[<"
30
-		for i, x := range s {
31
-			ss += x
32
-			if i < len(s)-1 {
33
-				ss += ">|<"
34
-			} else {
35
-				ss += ">]"
36
-			}
37
-		}
38
-	}
39
-	return
40
-}
41
-func getCommands(cmds def.Commands) (s []string) {
42
-	for i := range cmds {
43
-		s = append(s, i)
44
-	}
45
-	sort.Strings(s)
46
-	return
47
-}
48
-func getTokens(cmds def.Tokens) (s []string) {
49
-	for _, x := range cmds {
50
-		s = append(s, x.Value)
51
-	}
52
-	sort.Strings(s)
53
-	return
54
-}
55
-
56
-// Help prints out help information based on the contents of the commandline
57
-func Help(app *def.App) int {
58
-	fmt.Println(app.Name, app.Version(), "-", app.Tagline)
59
-	fmt.Println()
60
-	var tags []string
61
-	tags = append(tags, app.Commands["test"].Opts...)
62
-	if len(app.Tokens) == 1 {
63
-		fmt.Println("Help information for", app.Name)
64
-		fmt.Print(`+------------------------------------------------------+	
65
-|                                                      |
66
-|   To learn more about an item type its' regex        |
67
-|   pattern combined with the 'help' pattern           |
68
-|                                                      |
69
-|   eg:                                                |
70
-|       9 h l                                          |
71
-|                                                      |
72
-|   The command system is set-based and minimal, in    |
73
-|   most cases order does not matter, only the set of  |
74
-|   items being together in one line.                  |
75
-|                                                      |
76
-|   To configure the application, use 'conf'           |
77
-|   or edit the <datadir>/config file manually         |
78
-|                                                      |
79
-|   legend:                                            |
80
-|                                                      |
81
-|       <name>    'regex pattern'                      |
82
-|                 <short description>                  |
83
-+------------------------------------------------------+
84
-
85
-`)
86
-		// help was invoked
87
-		for i := range app.Commands {
88
-			tags = append(tags, i)
89
-		}
90
-		sort.Strings(tags)
91
-		for _, i := range app.Commands["help"].Opts {
92
-			tags = append(tags, i)
93
-		}
94
-		tags = util.Uniq(tags)
95
-		for _, x := range tags {
96
-			// if ac := app.Commands[x]; ac.Handler != nil {
97
-			ac := app.Commands[x]
98
-			fmt.Printf("%s\t'%s'\n\n",
99
-				x,
100
-				ac.Pattern,
101
-				// optTagList(ac.Opts),
102
-				// help.PrintDetail formats a help detail variable for terminal outputhort,
103
-				// help.PrintDetail(ac.Detail, "\t\t"),
104
-			)
105
-			// }
106
-		}
107
-	} else {
108
-		// some number of other commands were mentioned
109
-		fmt.Println(
110
-			"showing items mentioned alongside help in commandline:",
111
-			app.Tokens.GetSortedKeys(),
112
-		)
113
-		fmt.Println()
114
-		for i := range app.Tokens {
115
-			tags = append(tags, i)
116
-		}
117
-		util.Uniq(tags)
118
-		for _, h := range tags {
119
-			for _, i := range app.Commands[h].Opts {
120
-				tags = append(tags, i)
121
-			}
122
-		}
123
-		// Now we separate ones with handlers and put them at the top
124
-		// and add the others to the end
125
-		var commands, onlydata []string
126
-		for _, i := range tags {
127
-			if app.Commands[i].Handler == nil {
128
-				onlydata = append(onlydata, i)
129
-			} else {
130
-				commands = append(commands, i)
131
-			}
132
-		}
133
-		sort.Strings(commands)
134
-		sort.Strings(onlydata)
135
-		commands = util.Uniq(commands)
136
-		onlydata = util.Uniq(onlydata)
137
-		tags = append(commands, onlydata...)
138
-		var divided bool
139
-		fmt.Print("--- commands that invoke a process ---\n\n")
140
-		for _, x := range tags {
141
-			if x != "help" {
142
-				if app.Commands[x].Handler == nil && !divided {
143
-					fmt.Print("--- data only items ---\n\n")
144
-					divided = true
145
-				}
146
-				fmt.Printf("%s\n\tregex:'%s'\n\t%s\n\t%s\n\n%s\n\n",
147
-					x,
148
-					app.Commands[x].Pattern,
149
-					optTagList(app.Commands[x].Opts),
150
-					// help.PrintDetail formats a help detail variable for terminal output
151
-					app.Commands[x].Short,
152
-					help.PrintDetail(app.Commands[x].Detail, "\t"),
153
-				)
154
-			}
155
-		}
156
-	}
157
-	return 0
158
-}
159
-
160
-// Conf runs the configuration menu system
161
-func Conf(app *def.App) int {
162
-	var r int
163
-	for r = 2; r == 2; {
164
-		r = conf.Run(app)
165
-	}
166
-	return r
167
-}
168
-
169
-// List prints the available commands for ctl
170
-func List(app *def.App) int {
171
-	if j := g.ValidateProxyListeners(app); j != 0 {
172
-		return j
173
-	}
174
-	if _, ok := app.Tokens["wallet"]; ok {
175
-		app.Cats["wallet"]["enable"].Put(true)
176
-	}
177
-	ctl.ListCommands()
178
-	return 0
179
-}
180
-
181
-// Ctl sends RPC commands input in the command line arguments and prints the
182
-// result back to stdout
183
-func Ctl(app *def.App) int {
184
-	cl.Register.SetAllLevels(*app.Config.LogLevel)
185
-	g.SetAppDataDir(app, "ctl")
186
-	if j := g.ValidateProxyListeners(app); j != 0 {
187
-		return j
188
-	}
189
-	if _, ok := app.Tokens["wallet"]; ok {
190
-		*app.Config.Wallet = true
191
-	}
192
-
193
-	ctl.Main(app)
194
-	return 0
195
-}
196
-
197
-// Node launches the full node
198
-func Node(a9 *def.App) int {
199
-	cl.Register.SetAllLevels(*a9.Config.LogLevel)
200
-	g.SetAppDataDir(a9, "node")
201
-	if g.ValidateWhitelists(a9) != 0 ||
202
-		g.ValidateProxyListeners(a9) != 0 ||
203
-		g.ValidatePasswords(a9) != 0 ||
204
-		g.ValidateRPCCredentials(a9) != 0 ||
205
-		g.ValidateBlockLimits(a9) != 0 ||
206
-		g.ValidateUAComments(a9) != 0 ||
207
-		g.ValidateMiner(a9) != 0 ||
208
-		g.ValidateCheckpoints(a9) != 0 ||
209
-		g.ValidateAddresses(a9) != 0 ||
210
-		g.ValidateDialers(a9) != 0 {
211
-		return 1
212
-	}
213
-	a9.Started = make(chan struct{})
214
-	// run the node!
215
-	node.Main(a9.Config, a9.StateCfg, nil, a9.Started)
216
-	return 0
217
-}
218
-
219
-// Wallet launches the wallet server
220
-func Wallet(app *def.App) int {
221
-	g.SetAppDataDir(app, "wallet")
222
-	netDir := walletmain.NetworkDir(*app.Config.AppDataDir,
223
-		app.Config.ActiveNetParams.Params)
224
-	wdb := netDir // + "/wallet.db"
225
-	log <- cl.Debug{"opening wallet:", wdb}
226
-	if exists, _ := util.FileExists(wdb); !exists {
227
-		if e := walletmain.CreateWallet(
228
-			app.Config, app.Config.ActiveNetParams, wdb); e != nil {
229
-			panic("could not create wallet " + e.Error())
230
-		}
231
-	} else {
232
-		g.SetAppDataDir(app, "node")
233
-		if e := walletmain.Main(app.Config, app.Config.ActiveNetParams, netDir); e != nil {
234
-			return 1
235
-		}
236
-	}
237
-	return 0
238
-}
239
-
240
-// Shell runs a combined full node and wallet server for use in the common
241
-// standard configuration provided by many bitcoin and bitcoin fork servers
242
-func Shell(app *def.App) int {
243
-	g.SetAppDataDir(app, "node")
244
-	netDir := walletmain.NetworkDir(
245
-		filepath.Join(*app.Config.DataDir, "wallet"),
246
-		app.Config.ActiveNetParams.Params)
247
-	wdb := netDir // + "/wallet.db"
248
-	log <- cl.Debug{"opening wallet:", wdb}
249
-	if exists, _ := util.FileExists(wdb); !exists {
250
-		if e := walletmain.CreateWallet(
251
-			app.Config, app.Config.ActiveNetParams, wdb); e != nil {
252
-			panic("could not create wallet " + e.Error())
253
-		}
254
-	} else {
255
-		go Node(app)
256
-		<-app.Started
257
-		log <- cl.Info{"starting wallet server"}
258
-		if e := walletmain.Main(app.Config, app.Config.ActiveNetParams, netDir); e != nil {
259
-			return 1
260
-		}
261
-	}
262
-	return 0
263
-}
264
-
265
-// Create generates a set of configurations that are set to connect to each
266
-// other in a testnet
267
-func Create(app *def.App) int {
268
-	netDir := walletmain.NetworkDir(
269
-		filepath.Join(*app.Config.DataDir, "wallet"),
270
-		app.Config.ActiveNetParams.Params)
271
-	wdb := netDir // + "/wallet.db"
272
-	if exists, _ := util.FileExists(wdb); !exists {
273
-		if e := walletmain.CreateWallet(
274
-			app.Config, app.Config.ActiveNetParams, wdb); e != nil {
275
-			panic("could not create wallet " + e.Error())
276
-		}
277
-	} else {
278
-		fmt.Println("wallet already exists in", wdb+"/wallet.db", "refusing to overwrite")
279
-		return 1
280
-	}
281
-	return 0
282
-}
283
-
284
-// GUI runs a shell in the background and a GUI interface for wallet and node
285
-func GUI(app *def.App) int {
286
-	fmt.Println("Sorry, not implemented yet")
287
-	return 0
288
-}
289
-
290
-// Mine runs the standalone miner
291
-func Mine(app *def.App) int {
292
-	fmt.Println("Sorry, not implemented yet")
293
-	return 0
294
-}
295
-
296
-// GenCerts generates TLS certificates
297
-func GenCerts(app *def.App) int {
298
-	fmt.Println("Sorry, not implemented yet")
299
-	return 0
300
-}
301
-
302
-// GenCA creates a signing key that GenCerts will use if present to sign keys
303
-// that it can be used to certify for multiple nodes connected to each other
304
-// (wallet/node and RPC)
305
-func GenCA(app *def.App) int {
306
-	fmt.Println("Sorry, not implemented yet")
307
-	return 0
308
-}
309
-
310
-// TestHandler runs multiple instances of a node for a simple one machine
311
-// testnet. This includes also an instance of the wallet that connects to
312
-// one of the testnet, so transactions can be tested
313
-func TestHandler(a9 *def.App) int {
314
-	log <- cl.Info{"starting up testnet..."}
315
-	var nodes []*def.App
316
-	numtestnodes := *a9.Config.TestnetNumber
317
-	host, p, _ := net.SplitHostPort((*a9.Config.Listeners)[0])
318
-	portbase, _ := strconv.ParseInt(p, 10, 32)
319
-	nodes = append(nodes, a9)
320
-	var l []string
321
-	for j := 1; j < numtestnodes; j++ {
322
-		l = append(
323
-			l, net.JoinHostPort(
324
-				host, fmt.Sprint(int(portbase)+j*100)))
325
-	}
326
-	True := true
327
-	for i := 1; i < numtestnodes; i++ {
328
-		nodes = append(nodes, a9.Generator())
329
-		// Configure the apps to connect to each other correctly
330
-		var listeners []string
331
-		for j := 0; j < numtestnodes; j++ {
332
-			if j != i {
333
-				listeners = append(
334
-					listeners, net.JoinHostPort(
335
-						host, fmt.Sprint(int(portbase)+j*100)))
336
-			}
337
-		}
338
-		nodes[i].Cats["p2p"]["listen"].Put(listeners)
339
-		// and disable all but the first node's RPC
340
-		nodes[i].Cats["rpc"]["disable"].Put(true)
341
-		// disable mining generator on all but master
342
-		nodes[i].Cats["mining"]["generate"].Put(false)
343
-		nodes[i].Config = makeconf.MakeConfig(nodes[i])
344
-		nodes[i].Config.ActiveNetParams = node.ActiveNetParams
345
-		g.SetAppDataDir(nodes[0], fmt.Sprintf("testnet%d", i))
346
-		nodes[i].Config.TestNet3 = &True
347
-		go Node(nodes[i])
348
-	}
349
-	g.SetAppDataDir(nodes[0], "testnet0")
350
-	nodes[0].Config = makeconf.MakeConfig(nodes[0])
351
-	nodes[0].Config.ActiveNetParams = node.ActiveNetParams
352
-	nodes[0].Config.TestNet3 = &True
353
-	Shell(nodes[0])
354
-	return 0
355
-}

+ 140
- 0
pkg/app/help/gen.go View File

@@ -0,0 +1,140 @@
1
+package help
2
+
3
+import (
4
+	"fmt"
5
+	"sort"
6
+
7
+	"git.parallelcoin.io/dev/9/pkg/app/def"
8
+	"git.parallelcoin.io/dev/9/pkg/app/g"
9
+	"git.parallelcoin.io/dev/9/pkg/util"
10
+	"git.parallelcoin.io/dev/9/pkg/util/help"
11
+)
12
+
13
+var Gen = g.Cmd("help",
14
+	g.Pattern("^(h|help)$"),
15
+	g.Short("show help text and quit"),
16
+	g.Detail(
17
+		"any other command also mentioned with help",
18
+		"will have its detailed help information printed",
19
+	),
20
+	g.Precs("help"),
21
+	g.Handler(
22
+		func(app *def.App) int {
23
+			fmt.Println(app.Name, app.Version(), "-", app.Tagline)
24
+			fmt.Println()
25
+			var tags []string
26
+			tags = append(tags, app.Commands["test"].Opts...)
27
+			if len(app.Tokens) == 1 {
28
+				fmt.Println("Help information for", app.Name)
29
+				fmt.Print(`+------------------------------------------------------+	
30
+			|                                                      |
31
+			|   To learn more about an item type its' regex        |
32
+			|   pattern combined with the 'help' pattern           |
33
+			|                                                      |
34
+			|   eg:                                                |
35
+			|       9 h l                                          |
36
+			|                                                      |
37
+			|   The command system is set-based and minimal, in    |
38
+			|   most cases order does not matter, only the set of  |
39
+			|   items being together in one line.                  |
40
+			|                                                      |
41
+			|   To configure the application, use 'conf'           |
42
+			|   or edit the <datadir>/config file manually         |
43
+			|                                                      |
44
+			|   legend:                                            |
45
+			|                                                      |
46
+			|       <name>    'regex pattern'                      |
47
+			|                 <short description>                  |
48
+			+------------------------------------------------------+
49
+			
50
+			`)
51
+				// help was invoked
52
+				for i := range app.Commands {
53
+					tags = append(tags, i)
54
+				}
55
+				sort.Strings(tags)
56
+				for _, i := range app.Commands["help"].Opts {
57
+					tags = append(tags, i)
58
+				}
59
+				tags = util.Uniq(tags)
60
+				for _, x := range tags {
61
+					// if ac := app.Commands[x]; ac.Handler != nil {
62
+					ac := app.Commands[x]
63
+					fmt.Printf("%s\t'%s'\n\n",
64
+						x,
65
+						ac.Pattern,
66
+						// optTagList(ac.Opts),
67
+						// help.PrintDetail formats a help detail variable for terminal outputhort,
68
+						// help.PrintDetail(ac.Detail, "\t\t"),
69
+					)
70
+					// }
71
+				}
72
+			} else {
73
+				// some number of other commands were mentioned
74
+				fmt.Println(
75
+					"showing items mentioned alongside help in commandline:",
76
+					app.Tokens.GetSortedKeys(),
77
+				)
78
+				fmt.Println()
79
+				for i := range app.Tokens {
80
+					tags = append(tags, i)
81
+				}
82
+				util.Uniq(tags)
83
+				for _, h := range tags {
84
+					for _, i := range app.Commands[h].Opts {
85
+						tags = append(tags, i)
86
+					}
87
+				}
88
+				// Now we separate ones with handlers and put them at the top
89
+				// and add the others to the end
90
+				var commands, onlydata []string
91
+				for _, i := range tags {
92
+					if app.Commands[i].Handler == nil {
93
+						onlydata = append(onlydata, i)
94
+					} else {
95
+						commands = append(commands, i)
96
+					}
97
+				}
98
+				sort.Strings(commands)
99
+				sort.Strings(onlydata)
100
+				commands = util.Uniq(commands)
101
+				onlydata = util.Uniq(onlydata)
102
+				tags = append(commands, onlydata...)
103
+				var divided bool
104
+				fmt.Print("--- commands that invoke a process ---\n\n")
105
+				for _, x := range tags {
106
+					if x != "help" {
107
+						if app.Commands[x].Handler == nil && !divided {
108
+							fmt.Print("--- data only items ---\n\n")
109
+							divided = true
110
+						}
111
+						fmt.Printf("%s\n\tregex:'%s'\n\t%s\n\t%s\n\n%s\n\n",
112
+							x,
113
+							app.Commands[x].Pattern,
114
+							optTagList(app.Commands[x].Opts),
115
+							// help.PrintDetail formats a help detail variable for terminal output
116
+							app.Commands[x].Short,
117
+							help.PrintDetail(app.Commands[x].Detail, "\t"),
118
+						)
119
+					}
120
+				}
121
+			}
122
+			return 0
123
+		},
124
+	),
125
+)
126
+
127
+func optTagList(s []string) (ss string) {
128
+	if len(ss) > 1 {
129
+		ss = "[<"
130
+		for i, x := range s {
131
+			ss += x
132
+			if i < len(s)-1 {
133
+				ss += ">|<"
134
+			} else {
135
+				ss += ">]"
136
+			}
137
+		}
138
+	}
139
+	return
140
+}

+ 31
- 0
pkg/app/list/gen.go View File

@@ -0,0 +1,31 @@
1
+package list
2
+
3
+import (
4
+	"git.parallelcoin.io/dev/9/pkg/app/ctl"
5
+	"git.parallelcoin.io/dev/9/pkg/app/def"
6
+	"git.parallelcoin.io/dev/9/pkg/app/g"
7
+)
8
+
9
+var Gen = g.Cmd("list",
10
+	g.Pattern("^(l|list|listcommands)$"),
11
+	g.Short("lists commands available at the RPC endpoint"),
12
+	g.Detail("<datadir>\tis the enabled data directory",
13
+		"<ctl>\t\tmust be present to invoke list",
14
+		"<wallet>\tindicates to connect to the wallet RPC",
15
+		"<node>\t\t(or wallet not specified) connect to full node RPC",
16
+	),
17
+	g.Opts("datadir", "ctl", "wallet", "node"),
18
+	g.Precs("help"),
19
+	g.Handler(
20
+		func(app *def.App) int {
21
+			if j := g.ValidateProxyListeners(app); j != 0 {
22
+				return j
23
+			}
24
+			if _, ok := app.Tokens["wallet"]; ok {
25
+				app.Cats["wallet"]["enable"].Put(true)
26
+			}
27
+			ctl.ListCommands()
28
+			return 0
29
+		},
30
+	),
31
+)

+ 22
- 0
pkg/app/mine/gen.go View File

@@ -0,0 +1,22 @@
1
+package mine
2
+
3
+import (
4
+	"fmt"
5
+
6
+	"git.parallelcoin.io/dev/9/pkg/app/def"
7
+	"git.parallelcoin.io/dev/9/pkg/app/g"
8
+)
9
+
10
+var Gen = g.Cmd("mine",
11
+	g.Pattern("^(m|mine)$"),
12
+	g.Short("run the standalone miner"),
13
+	g.Detail("runs a standalone miner to dig for parallelcoins"),
14
+	g.Opts("datadir"),
15
+	g.Precs("help"),
16
+	g.Handler(
17
+		func(app *def.App) int {
18
+			fmt.Println("Sorry, not implemented yet")
19
+			return 0
20
+		},
21
+	),
22
+)

+ 41
- 0
pkg/app/node/gen.go View File

@@ -0,0 +1,41 @@
1
+package node
2
+
3
+import (
4
+	"git.parallelcoin.io/dev/9/pkg/app/def"
5
+	"git.parallelcoin.io/dev/9/pkg/app/g"
6
+	"git.parallelcoin.io/dev/9/pkg/node"
7
+	"git.parallelcoin.io/dev/9/pkg/util/cl"
8
+)
9
+
10
+var Gen = g.Cmd("node",
11
+	g.Pattern("^(n|node)$"),
12
+	g.Short("runs a full node"),
13
+	g.Detail(
14
+		"<datadir>\tsets the data directory to read configuration",
15
+		"\t\tand store data",
16
+	),
17
+	g.Opts("datadir"),
18
+	g.Precs("help", "ctl", "list"),
19
+	g.Handler(
20
+		func(a9 *def.App) int {
21
+			cl.Register.SetAllLevels(*a9.Config.LogLevel)
22
+			g.SetAppDataDir(a9, "node")
23
+			if g.ValidateWhitelists(a9) != 0 ||
24
+				g.ValidateProxyListeners(a9) != 0 ||
25
+				g.ValidatePasswords(a9) != 0 ||
26
+				g.ValidateRPCCredentials(a9) != 0 ||
27
+				g.ValidateBlockLimits(a9) != 0 ||
28
+				g.ValidateUAComments(a9) != 0 ||
29
+				g.ValidateMiner(a9) != 0 ||
30
+				g.ValidateCheckpoints(a9) != 0 ||
31
+				g.ValidateAddresses(a9) != 0 ||
32
+				g.ValidateDialers(a9) != 0 {
33
+				return 1
34
+			}
35
+			a9.Started = make(chan struct{})
36
+			// run the node!
37
+			node.Main(a9.Config, a9.StateCfg, nil, a9.Started)
38
+			return 0
39
+		},
40
+	),
41
+)

+ 12
- 0
pkg/app/param/gen.go View File

@@ -41,4 +41,16 @@ var Gen = []def.AppGenerator{
41 41
 		g.Opts(),
42 42
 		g.Precs("help"),
43 43
 	),
44
+	g.Cmd("log",
45
+		g.Pattern("^(L|log)$"),
46
+		g.Short(
47
+			"write to log in <datadir> file instead of printing to console",
48
+		),
49
+		g.Detail(
50
+			"<datadir>\tsets the data directory where the wallet will",
51
+			"\t\tbe stored",
52
+		),
53
+		g.Opts(),
54
+		g.Precs("help", "node", "wallet", "shell", "test"),
55
+	),
44 56
 }

+ 40
- 0
pkg/app/shell/gen.go View File

@@ -0,0 +1,40 @@
1
+package shell
2
+
3
+import (
4
+	"git.parallelcoin.io/dev/9/pkg/app/def"
5
+	"git.parallelcoin.io/dev/9/pkg/app/g"
6
+)
7
+
8
+var Gen = g.Cmd("shell",
9
+	g.Pattern("^(s|shell)$"),
10
+	g.Short("runs a combined node/wallet server"),
11
+	g.Detail(
12
+		"<datadir>\tsets the data directory to read configuration and", "\t\tdata",
13
+	),
14
+	g.Opts("datadir", "create"),
15
+	g.Precs("help"),
16
+	g.Handler(
17
+		func(app *def.App) int {
18
+			// g.SetAppDataDir(app, "node")
19
+			// netDir := walletmain.NetworkDir(
20
+			// 	filepath.Join(*app.Config.DataDir, "wallet"),
21
+			// 	app.Config.ActiveNetParams.Params)
22
+			// wdb := netDir // + "/wallet.db"
23
+			// log <- cl.Debug{"opening wallet:", wdb}
24
+			// if exists, _ := util.FileExists(wdb); !exists {
25
+			// 	if e := walletmain.CreateWallet(
26
+			// 		app.Config, app.Config.ActiveNetParams, wdb); e != nil {
27
+			// 		panic("could not create wallet " + e.Error())
28
+			// 	}
29
+			// } else {
30
+			// go Node(app)
31
+			// <-app.Started
32
+			// log <- cl.Info{"starting wallet server"}
33
+			// 	if e := walletmain.Main(app.Config, app.Config.ActiveNetParams, netDir); e != nil {
34
+			// 		return 1
35
+			// 	}
36
+			// }
37
+			return 0
38
+		},
39
+	),
40
+)

+ 68
- 0
pkg/app/test/gen.go View File

@@ -0,0 +1,68 @@
1
+package test
2
+
3
+import (
4
+	"git.parallelcoin.io/dev/9/pkg/app/def"
5
+	"git.parallelcoin.io/dev/9/pkg/app/g"
6
+)
7
+
8
+var Gen = g.Cmd("test",
9
+	g.Pattern("^(t|test)$"),
10
+	g.Short("run multiple full nodes"),
11
+	g.Detail(
12
+		"<datadir>\tindicates the basename to search for as the",
13
+		"\t\tpath to the test configurations",
14
+		"<log>\t\tindicates to write logs to the individual data",
15
+		"\t\tdirectories instead of print to stdout",
16
+		"<integer>\tindicates how many nodes to create (minimum 2)",
17
+		"",
18
+		"Note that the configured wallet and node ports will be",
19
+		"the only ports listening for testing RPC and transactions.",
20
+	),
21
+	g.Opts("datadir", "log", "integer"),
22
+	g.Precs("help"),
23
+	g.Handler(
24
+		func(a9 *def.App) int {
25
+			// log <- cl.Info{"starting up testnet..."}
26
+			// var nodes []*def.App
27
+			// numtestnodes := *a9.Config.TestnetNumber
28
+			// host, p, _ := net.SplitHostPort((*a9.Config.Listeners)[0])
29
+			// portbase, _ := strconv.ParseInt(p, 10, 32)
30
+			// nodes = append(nodes, a9)
31
+			// var l []string
32
+			// for j := 1; j < numtestnodes; j++ {
33
+			// 	l = append(
34
+			// 		l, net.JoinHostPort(
35
+			// 			host, fmt.Sprint(int(portbase)+j*100)))
36
+			// }
37
+			// True := true
38
+			// for i := 1; i < numtestnodes; i++ {
39
+			// 	nodes = append(nodes, a9.Generator())
40
+			// 	// Configure the apps to connect to each other correctly
41
+			// 	var listeners []string
42
+			// 	for j := 0; j < numtestnodes; j++ {
43
+			// 		if j != i {
44
+			// 			listeners = append(
45
+			// 				listeners, net.JoinHostPort(
46
+			// 					host, fmt.Sprint(int(portbase)+j*100)))
47
+			// 		}
48
+			// 	}
49
+			// 	nodes[i].Cats["p2p"]["listen"].Put(listeners)
50
+			// 	// and disable all but the first node's RPC
51
+			// 	nodes[i].Cats["rpc"]["disable"].Put(true)
52
+			// 	// disable mining generator on all but master
53
+			// 	nodes[i].Cats["mining"]["generate"].Put(false)
54
+			// 	nodes[i].Config = makeconf.MakeConfig(nodes[i])
55
+			// 	nodes[i].Config.ActiveNetParams = node.ActiveNetParams
56
+			// 	g.SetAppDataDir(nodes[0], fmt.Sprintf("testnet%d", i))
57
+			// 	nodes[i].Config.TestNet3 = &True
58
+			// 	go Node(nodes[i])
59
+			// }
60
+			// g.SetAppDataDir(nodes[0], "testnet0")
61
+			// nodes[0].Config = makeconf.MakeConfig(nodes[0])
62
+			// nodes[0].Config.ActiveNetParams = node.ActiveNetParams
63
+			// nodes[0].Config.TestNet3 = &True
64
+			// Shell(nodes[0])
65
+			return 0
66
+		},
67
+	),
68
+)

+ 39
- 0
pkg/app/wallet/gen.go View File

@@ -0,0 +1,39 @@
1
+package wallet
2
+
3
+import (
4
+	"git.parallelcoin.io/dev/9/pkg/app/def"
5
+	"git.parallelcoin.io/dev/9/pkg/app/g"
6
+	"git.parallelcoin.io/dev/9/pkg/util"
7
+	walletmain "git.parallelcoin.io/dev/9/pkg/wallet/main"
8
+)
9
+
10
+var Gen = g.Cmd("wallet",
11
+	g.Pattern("^(w|wallet)$"),
12
+	g.Short("runs a wallet server"),
13
+	g.Detail(
14
+		"<datadir>\tsets the data directory to read configuration and", "\t\tstore data",
15
+		"<create>\truns the wallet create prompt",
16
+	),
17
+	g.Opts("datadir", "create"),
18
+	g.Precs("help", "ctl", "list"),
19
+	g.Handler(
20
+		func(app *def.App) int {
21
+			g.SetAppDataDir(app, "wallet")
22
+			netDir := walletmain.NetworkDir(*app.Config.AppDataDir,
23
+				app.Config.ActiveNetParams.Params)
24
+			wdb := netDir // + "/wallet.db"
25
+			if exists, _ := util.FileExists(wdb); !exists {
26
+				if e := walletmain.CreateWallet(
27
+					app.Config, app.Config.ActiveNetParams, wdb); e != nil {
28
+					panic("could not create wallet " + e.Error())
29
+				}
30
+			} else {
31
+				g.SetAppDataDir(app, "node")
32
+				if e := walletmain.Main(app.Config, app.Config.ActiveNetParams, netDir); e != nil {
33
+					return 1
34
+				}
35
+			}
36
+			return 0
37
+		},
38
+	),
39
+)

+ 0
- 0
pkg/chain/README.md View File


+ 0
- 0
pkg/chain/accept.go View File


+ 0
- 0
pkg/chain/bench_test.go View File


+ 0
- 0
pkg/chain/blockindex.go View File


+ 0
- 0
pkg/chain/chain.go View File


+ 0
- 0
pkg/chain/chain_test.go View File


+ 0
- 0
pkg/chain/chainio.go View File


+ 0
- 0
pkg/chain/chainio_test.go View File


+ 0
- 0
pkg/chain/chainview.go View File


+ 0
- 0
pkg/chain/chainview_test.go View File


+ 0
- 0
pkg/chain/checkpoints.go View File


+ 0
- 0
pkg/chain/common_test.go View File


+ 0
- 0
pkg/chain/compress.go View File


+ 0
- 0
pkg/chain/compress_test.go View File


+ 0
- 0
pkg/chain/config/README.md View File


+ 0
- 0
pkg/chain/config/doc.go View File


+ 0
- 0
pkg/chain/config/genesis.go View File


+ 0
- 0
pkg/chain/config/genesis_test.go View File


+ 0
- 0
pkg/chain/config/params-defs.go View File


+ 0
- 0
pkg/chain/config/params-mainnet.go View File


+ 0
- 0
pkg/chain/config/params-regtest.go View File


+ 0
- 0
pkg/chain/config/params-simnet.go View File


+ 0
- 0
pkg/chain/config/params-testnet.go View File


+ 0
- 0
pkg/chain/config/params.go View File


+ 0
- 0
pkg/chain/config/params/params.go View File


+ 0
- 0
pkg/chain/config/params_test.go View File


+ 0
- 0
pkg/chain/config/register_test.go View File


+ 0
- 0
pkg/chain/config/util.go View File


+ 0
- 0
pkg/chain/difficulty.go View File


+ 0
- 0
pkg/chain/difficulty_test.go View File


+ 0
- 0
pkg/chain/doc.go View File


+ 0
- 0
pkg/chain/error.go View File


+ 0
- 0
pkg/chain/error_test.go View File


+ 0
- 0
pkg/chain/example_test.go View File


+ 0
- 0
pkg/chain/fork/bench/bench.go View File


+ 0
- 0
pkg/chain/fork/bits.go View File


+ 0
- 0
pkg/chain/fork/expdecay.go View File


+ 0
- 0
pkg/chain/fork/fork.go View File


+ 0
- 0
pkg/chain/fork/hash.go View File


+ 0
- 0
pkg/chain/fullblocktests/fullblocks_test.go View File


+ 0
- 0
pkg/chain/hash/README.md View File


+ 0
- 0
pkg/chain/hash/doc.go View File


+ 0
- 0
pkg/chain/hash/hash.go View File


+ 0
- 0
pkg/chain/hash/hash_test.go View File


+ 0
- 0
pkg/chain/hash/hashfuncs.go View File


+ 0
- 0
pkg/chain/hash/hashfuncs_test.go View File


+ 0
- 0
pkg/chain/index/README.md View File


+ 0
- 0
pkg/chain/index/addrindex.go View File


+ 0
- 0
pkg/chain/index/addrindex_test.go View File


+ 0
- 0
pkg/chain/index/blocklogger.go View File


+ 0
- 0
pkg/chain/index/cfindex.go View File


+ 0
- 0
pkg/chain/index/common.go View File


+ 0
- 0
pkg/chain/index/log.go View File


+ 0
- 0
pkg/chain/index/manager.go View File


+ 0
- 0
pkg/chain/index/txindex.go View File


+ 0
- 0
pkg/chain/log.go View File


+ 0
- 0
pkg/chain/mediantime.go View File


+ 0
- 0
pkg/chain/mediantime_test.go View File


+ 0
- 0
pkg/chain/merkle.go View File


+ 0
- 0
pkg/chain/merkle_test.go View File


+ 0
- 0
pkg/chain/mining/README.md View File


+ 0
- 0
pkg/chain/mining/cpu/README.md View File


+ 0
- 0
pkg/chain/mining/cpu/cpuminer.go View File


+ 0
- 0
pkg/chain/mining/cpu/log.go View File


+ 0
- 0
pkg/chain/mining/dispatch/README.md View File


+ 0
- 0
pkg/chain/mining/dispatch/cmd/client/client.go View File


+ 0
- 0
pkg/chain/mining/dispatch/cmd/server/server.go View File


+ 0
- 0
pkg/chain/mining/dispatch/controller.go View File


+ 0
- 0
pkg/chain/mining/dispatch/controller_test.go View File


+ 0
- 0
pkg/chain/mining/dispatch/kopach.go View File


+ 0
- 0
pkg/chain/mining/dispatch/log.go View File


+ 0
- 0
pkg/chain/mining/log.go View File


+ 0
- 0
pkg/chain/mining/mining.go View File


+ 0
- 0
pkg/chain/mining/mining_test.go View File


+ 0
- 0
pkg/chain/mining/policy.go View File


+ 0
- 0
pkg/chain/mining/policy_test.go View File


+ 0
- 0
pkg/chain/notifications.go View File


+ 0
- 0
pkg/chain/notifications_test.go View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save