aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorViktor TrĂ³n <viktor.tron@gmail.com>2016-11-28 20:29:33 +0800
committerFelix Lange <fjl@twurst.com>2016-11-28 20:29:33 +0800
commite949a2ed2f1c59ed5ff1f187ad987c882656e6ef (patch)
tree836c8b977ef61ddbc8163f70cbed118825822cbe /cmd
parent8d0108fc5df81c71010b9dfb11a5db5658fcb80a (diff)
downloadgo-tangerine-e949a2ed2f1c59ed5ff1f187ad987c882656e6ef.tar.gz
go-tangerine-e949a2ed2f1c59ed5ff1f187ad987c882656e6ef.tar.zst
go-tangerine-e949a2ed2f1c59ed5ff1f187ad987c882656e6ef.zip
cmd/bzzd: swarm daemon fixes (#3359)
* cmd/bzzd: add missing p2p/discovery flags * cmd/bzzd: fix two bugs crashing bzzd if bootnodes flag given * cmd/bzzd: make no swap default, renamed flag bzznoswap->bzzswap * internal/web3ext: correct methods for bzz IPC module * cmd/bzzd: ethapi param not mandatory. Warning if no blockchain * cmd/bzzd: correct default IPC modules in help string * cmd/utils: fix help description for networkId - add Ropsten * cmd/bzz, swarm/api, swarm/network: add swarm networkId flag * cmd/bzzd: change nosync flag to sync and BootTFlag
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bzzd/main.go51
-rw-r--r--cmd/utils/flags.go2
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{