diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/bzzd/main.go | 51 | ||||
-rw-r--r-- | cmd/utils/flags.go | 2 |
2 files changed, 34 insertions, 19 deletions
diff --git a/cmd/bzzd/main.go b/cmd/bzzd/main.go index a3e87dc8a..4bb2ca04a 100644 --- a/cmd/bzzd/main.go +++ b/cmd/bzzd/main.go @@ -23,6 +23,7 @@ import ( "os" "runtime" "strconv" + "strings" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/cmd/utils" @@ -38,6 +39,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/swarm" bzzapi "github.com/ethereum/go-ethereum/swarm/api" + "github.com/ethereum/go-ethereum/swarm/network" "gopkg.in/urfave/cli.v1" ) @@ -61,17 +63,22 @@ var ( Name: "bzzport", Usage: "Swarm local http api port", } + SwarmNetworkIdFlag = cli.IntFlag{ + Name: "bzznetworkid", + Usage: "Network identifier (integer, default 322=swarm testnet)", + Value: network.NetworkId, + } SwarmConfigPathFlag = cli.StringFlag{ Name: "bzzconfig", Usage: "Swarm config file path (datadir/bzz)", } - SwarmSwapDisabled = cli.BoolFlag{ - Name: "bzznoswap", - Usage: "Swarm SWAP disabled (default false)", + SwarmSwapEnabled = cli.BoolFlag{ + Name: "swap", + Usage: "Swarm SWAP enabled (default false)", } - SwarmSyncDisabled = cli.BoolFlag{ - Name: "bzznosync", - Usage: "Swarm Syncing disabled (default false)", + SwarmSyncEnabled = cli.BoolTFlag{ + Name: "sync", + Usage: "Swarm Syncing enabled (default true)", } EthAPI = cli.StringFlag{ Name: "ethapi", @@ -86,6 +93,7 @@ func init() { // Override flag defaults so bzzd can run alongside geth. utils.ListenPortFlag.Value = 30399 utils.IPCPathFlag.Value = utils.DirectoryString{Value: "bzzd.ipc"} + utils.IPCApiFlag.Value = "admin, bzz, chequebook, debug, rpc, web3" // Set up the cli app. app.Commands = nil @@ -96,21 +104,24 @@ func init() { utils.BootnodesFlag, utils.KeyStoreDirFlag, utils.ListenPortFlag, + utils.NoDiscoverFlag, + utils.DiscoveryV5Flag, utils.NetrestrictFlag, - utils.MaxPeersFlag, - utils.NATFlag, utils.NodeKeyFileFlag, utils.NodeKeyHexFlag, + utils.MaxPeersFlag, + utils.NATFlag, utils.IPCDisabledFlag, utils.IPCApiFlag, utils.IPCPathFlag, // bzzd-specific flags EthAPI, SwarmConfigPathFlag, - SwarmSwapDisabled, - SwarmSyncDisabled, + SwarmSwapEnabled, + SwarmSyncEnabled, SwarmPortFlag, SwarmAccountFlag, + SwarmNetworkIdFlag, ChequebookAddrFlag, } app.Flags = append(app.Flags, debug.Flags...) @@ -138,7 +149,8 @@ func bzzd(ctx *cli.Context) error { // Add bootnodes as initial peers. if ctx.GlobalIsSet(utils.BootnodesFlag.Name) { - injectBootnodes(stack.Server(), ctx.GlobalStringSlice(utils.BootnodesFlag.Name)) + bootnodes := strings.Split(ctx.GlobalString(utils.BootnodesFlag.Name), ",") + injectBootnodes(stack.Server(), bootnodes) } else { injectBootnodes(stack.Server(), defaultBootnodes) } @@ -155,7 +167,7 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) { if bzzdir == "" { bzzdir = stack.InstanceDir() } - bzzconfig, err := bzzapi.NewConfig(bzzdir, chbookaddr, prvkey) + bzzconfig, err := bzzapi.NewConfig(bzzdir, chbookaddr, prvkey, ctx.GlobalUint64(SwarmNetworkIdFlag.Name)) if err != nil { utils.Fatalf("unable to configure swarm: %v", err) } @@ -163,16 +175,18 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) { if len(bzzport) > 0 { bzzconfig.Port = bzzport } - swapEnabled := !ctx.GlobalBool(SwarmSwapDisabled.Name) - syncEnabled := !ctx.GlobalBool(SwarmSyncDisabled.Name) + swapEnabled := ctx.GlobalBool(SwarmSwapEnabled.Name) + syncEnabled := ctx.GlobalBoolT(SwarmSyncEnabled.Name) ethapi := ctx.GlobalString(EthAPI.Name) - if ethapi == "" { - utils.Fatalf("Option %q must not be empty", EthAPI.Name) - } boot := func(ctx *node.ServiceContext) (node.Service, error) { - client, err := ethclient.Dial(ethapi) + var client *ethclient.Client + if ethapi == "" { + err = fmt.Errorf("use ethapi flag to connect to a an eth client and talk to the blockchain") + } else { + client, err = ethclient.Dial(ethapi) + } if err != nil { utils.Fatalf("Can't connect: %v", err) } @@ -241,6 +255,7 @@ func injectBootnodes(srv *p2p.Server, nodes []string) { n, err := discover.ParseNode(url) if err != nil { glog.Errorf("invalid bootnode %q", err) + continue } srv.AddPeer(n) } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index cb91f4539..abd344df0 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -116,7 +116,7 @@ var ( } NetworkIdFlag = cli.IntFlag{ Name: "networkid", - Usage: "Network identifier (integer, 0=Olympic, 1=Frontier, 2=Morden)", + Usage: "Network identifier (integer, 0=Olympic (disused), 1=Frontier, 2=Morden (disused), 3=Ropsten)", Value: eth.NetworkId, } OlympicFlag = cli.BoolFlag{ |