@@ -23,6 +23,7 @@ import (
2323 "os"
2424 "runtime"
2525 "strconv"
26+ "strings"
2627
2728 "github.com/ethereum/go-ethereum/accounts"
2829 "github.com/ethereum/go-ethereum/cmd/utils"
@@ -38,6 +39,7 @@ import (
3839 "github.com/ethereum/go-ethereum/p2p/discover"
3940 "github.com/ethereum/go-ethereum/swarm"
4041 bzzapi "github.com/ethereum/go-ethereum/swarm/api"
42+ "github.com/ethereum/go-ethereum/swarm/network"
4143 "gopkg.in/urfave/cli.v1"
4244)
4345
@@ -61,17 +63,22 @@ var (
6163 Name : "bzzport" ,
6264 Usage : "Swarm local http api port" ,
6365 }
66+ SwarmNetworkIdFlag = cli.IntFlag {
67+ Name : "bzznetworkid" ,
68+ Usage : "Network identifier (integer, default 322=swarm testnet)" ,
69+ Value : network .NetworkId ,
70+ }
6471 SwarmConfigPathFlag = cli.StringFlag {
6572 Name : "bzzconfig" ,
6673 Usage : "Swarm config file path (datadir/bzz)" ,
6774 }
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)" ,
7178 }
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 )" ,
7582 }
7683 EthAPI = cli.StringFlag {
7784 Name : "ethapi" ,
@@ -86,6 +93,7 @@ func init() {
8693 // Override flag defaults so bzzd can run alongside geth.
8794 utils .ListenPortFlag .Value = 30399
8895 utils .IPCPathFlag .Value = utils.DirectoryString {Value : "bzzd.ipc" }
96+ utils .IPCApiFlag .Value = "admin, bzz, chequebook, debug, rpc, web3"
8997
9098 // Set up the cli app.
9199 app .Commands = nil
@@ -96,21 +104,24 @@ func init() {
96104 utils .BootnodesFlag ,
97105 utils .KeyStoreDirFlag ,
98106 utils .ListenPortFlag ,
107+ utils .NoDiscoverFlag ,
108+ utils .DiscoveryV5Flag ,
99109 utils .NetrestrictFlag ,
100- utils .MaxPeersFlag ,
101- utils .NATFlag ,
102110 utils .NodeKeyFileFlag ,
103111 utils .NodeKeyHexFlag ,
112+ utils .MaxPeersFlag ,
113+ utils .NATFlag ,
104114 utils .IPCDisabledFlag ,
105115 utils .IPCApiFlag ,
106116 utils .IPCPathFlag ,
107117 // bzzd-specific flags
108118 EthAPI ,
109119 SwarmConfigPathFlag ,
110- SwarmSwapDisabled ,
111- SwarmSyncDisabled ,
120+ SwarmSwapEnabled ,
121+ SwarmSyncEnabled ,
112122 SwarmPortFlag ,
113123 SwarmAccountFlag ,
124+ SwarmNetworkIdFlag ,
114125 ChequebookAddrFlag ,
115126 }
116127 app .Flags = append (app .Flags , debug .Flags ... )
@@ -138,7 +149,8 @@ func bzzd(ctx *cli.Context) error {
138149
139150 // Add bootnodes as initial peers.
140151 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 )
142154 } else {
143155 injectBootnodes (stack .Server (), defaultBootnodes )
144156 }
@@ -155,24 +167,26 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
155167 if bzzdir == "" {
156168 bzzdir = stack .InstanceDir ()
157169 }
158- bzzconfig , err := bzzapi .NewConfig (bzzdir , chbookaddr , prvkey )
170+ bzzconfig , err := bzzapi .NewConfig (bzzdir , chbookaddr , prvkey , ctx . GlobalUint64 ( SwarmNetworkIdFlag . Name ) )
159171 if err != nil {
160172 utils .Fatalf ("unable to configure swarm: %v" , err )
161173 }
162174 bzzport := ctx .GlobalString (SwarmPortFlag .Name )
163175 if len (bzzport ) > 0 {
164176 bzzconfig .Port = bzzport
165177 }
166- swapEnabled := ! ctx .GlobalBool (SwarmSwapDisabled .Name )
167- syncEnabled := ! ctx .GlobalBool ( SwarmSyncDisabled .Name )
178+ swapEnabled := ctx .GlobalBool (SwarmSwapEnabled .Name )
179+ syncEnabled := ctx .GlobalBoolT ( SwarmSyncEnabled .Name )
168180
169181 ethapi := ctx .GlobalString (EthAPI .Name )
170- if ethapi == "" {
171- utils .Fatalf ("Option %q must not be empty" , EthAPI .Name )
172- }
173182
174183 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+ }
176190 if err != nil {
177191 utils .Fatalf ("Can't connect: %v" , err )
178192 }
@@ -241,6 +255,7 @@ func injectBootnodes(srv *p2p.Server, nodes []string) {
241255 n , err := discover .ParseNode (url )
242256 if err != nil {
243257 glog .Errorf ("invalid bootnode %q" , err )
258+ continue
244259 }
245260 srv .AddPeer (n )
246261 }
0 commit comments