@@ -23,6 +23,7 @@ import (
23
23
"os"
24
24
"runtime"
25
25
"strconv"
26
+ "strings"
26
27
27
28
"github.com/ethereum/go-ethereum/accounts"
28
29
"github.com/ethereum/go-ethereum/cmd/utils"
@@ -38,6 +39,7 @@ import (
38
39
"github.com/ethereum/go-ethereum/p2p/discover"
39
40
"github.com/ethereum/go-ethereum/swarm"
40
41
bzzapi "github.com/ethereum/go-ethereum/swarm/api"
42
+ "github.com/ethereum/go-ethereum/swarm/network"
41
43
"gopkg.in/urfave/cli.v1"
42
44
)
43
45
@@ -61,17 +63,22 @@ var (
61
63
Name : "bzzport" ,
62
64
Usage : "Swarm local http api port" ,
63
65
}
66
+ SwarmNetworkIdFlag = cli.IntFlag {
67
+ Name : "bzznetworkid" ,
68
+ Usage : "Network identifier (integer, default 322=swarm testnet)" ,
69
+ Value : network .NetworkId ,
70
+ }
64
71
SwarmConfigPathFlag = cli.StringFlag {
65
72
Name : "bzzconfig" ,
66
73
Usage : "Swarm config file path (datadir/bzz)" ,
67
74
}
68
- SwarmSwapDisabled = cli.BoolFlag {
69
- Name : "bzznoswap " ,
70
- Usage : "Swarm SWAP disabled (default false)" ,
75
+ SwarmSwapEnabled = cli.BoolFlag {
76
+ Name : "swap " ,
77
+ Usage : "Swarm SWAP enabled (default false)" ,
71
78
}
72
- SwarmSyncDisabled = cli.BoolFlag {
73
- Name : "bzznosync " ,
74
- Usage : "Swarm Syncing disabled (default false )" ,
79
+ SwarmSyncEnabled = cli.BoolTFlag {
80
+ Name : "sync " ,
81
+ Usage : "Swarm Syncing enabled (default true )" ,
75
82
}
76
83
EthAPI = cli.StringFlag {
77
84
Name : "ethapi" ,
@@ -86,6 +93,7 @@ func init() {
86
93
// Override flag defaults so bzzd can run alongside geth.
87
94
utils .ListenPortFlag .Value = 30399
88
95
utils .IPCPathFlag .Value = utils.DirectoryString {Value : "bzzd.ipc" }
96
+ utils .IPCApiFlag .Value = "admin, bzz, chequebook, debug, rpc, web3"
89
97
90
98
// Set up the cli app.
91
99
app .Commands = nil
@@ -96,21 +104,24 @@ func init() {
96
104
utils .BootnodesFlag ,
97
105
utils .KeyStoreDirFlag ,
98
106
utils .ListenPortFlag ,
107
+ utils .NoDiscoverFlag ,
108
+ utils .DiscoveryV5Flag ,
99
109
utils .NetrestrictFlag ,
100
- utils .MaxPeersFlag ,
101
- utils .NATFlag ,
102
110
utils .NodeKeyFileFlag ,
103
111
utils .NodeKeyHexFlag ,
112
+ utils .MaxPeersFlag ,
113
+ utils .NATFlag ,
104
114
utils .IPCDisabledFlag ,
105
115
utils .IPCApiFlag ,
106
116
utils .IPCPathFlag ,
107
117
// bzzd-specific flags
108
118
EthAPI ,
109
119
SwarmConfigPathFlag ,
110
- SwarmSwapDisabled ,
111
- SwarmSyncDisabled ,
120
+ SwarmSwapEnabled ,
121
+ SwarmSyncEnabled ,
112
122
SwarmPortFlag ,
113
123
SwarmAccountFlag ,
124
+ SwarmNetworkIdFlag ,
114
125
ChequebookAddrFlag ,
115
126
}
116
127
app .Flags = append (app .Flags , debug .Flags ... )
@@ -138,7 +149,8 @@ func bzzd(ctx *cli.Context) error {
138
149
139
150
// Add bootnodes as initial peers.
140
151
if ctx .GlobalIsSet (utils .BootnodesFlag .Name ) {
141
- injectBootnodes (stack .Server (), ctx .GlobalStringSlice (utils .BootnodesFlag .Name ))
152
+ bootnodes := strings .Split (ctx .GlobalString (utils .BootnodesFlag .Name ), "," )
153
+ injectBootnodes (stack .Server (), bootnodes )
142
154
} else {
143
155
injectBootnodes (stack .Server (), defaultBootnodes )
144
156
}
@@ -155,24 +167,26 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
155
167
if bzzdir == "" {
156
168
bzzdir = stack .InstanceDir ()
157
169
}
158
- bzzconfig , err := bzzapi .NewConfig (bzzdir , chbookaddr , prvkey )
170
+ bzzconfig , err := bzzapi .NewConfig (bzzdir , chbookaddr , prvkey , ctx . GlobalUint64 ( SwarmNetworkIdFlag . Name ) )
159
171
if err != nil {
160
172
utils .Fatalf ("unable to configure swarm: %v" , err )
161
173
}
162
174
bzzport := ctx .GlobalString (SwarmPortFlag .Name )
163
175
if len (bzzport ) > 0 {
164
176
bzzconfig .Port = bzzport
165
177
}
166
- swapEnabled := ! ctx .GlobalBool (SwarmSwapDisabled .Name )
167
- syncEnabled := ! ctx .GlobalBool ( SwarmSyncDisabled .Name )
178
+ swapEnabled := ctx .GlobalBool (SwarmSwapEnabled .Name )
179
+ syncEnabled := ctx .GlobalBoolT ( SwarmSyncEnabled .Name )
168
180
169
181
ethapi := ctx .GlobalString (EthAPI .Name )
170
- if ethapi == "" {
171
- utils .Fatalf ("Option %q must not be empty" , EthAPI .Name )
172
- }
173
182
174
183
boot := func (ctx * node.ServiceContext ) (node.Service , error ) {
175
- client , err := ethclient .Dial (ethapi )
184
+ var client * ethclient.Client
185
+ if ethapi == "" {
186
+ err = fmt .Errorf ("use ethapi flag to connect to a an eth client and talk to the blockchain" )
187
+ } else {
188
+ client , err = ethclient .Dial (ethapi )
189
+ }
176
190
if err != nil {
177
191
utils .Fatalf ("Can't connect: %v" , err )
178
192
}
@@ -241,6 +255,7 @@ func injectBootnodes(srv *p2p.Server, nodes []string) {
241
255
n , err := discover .ParseNode (url )
242
256
if err != nil {
243
257
glog .Errorf ("invalid bootnode %q" , err )
258
+ continue
244
259
}
245
260
srv .AddPeer (n )
246
261
}
0 commit comments