mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
swarm: read format and comment docs, updated
fixes ethereum/go-ethereum#3444
This commit is contained in:
parent
b520d7caa5
commit
5fb1c2a601
2 changed files with 10 additions and 12 deletions
|
|
@ -76,8 +76,6 @@ var (
|
||||||
SwarmNetworkIdFlag = cli.IntFlag{
|
SwarmNetworkIdFlag = cli.IntFlag{
|
||||||
Name: "bzznetworkid",
|
Name: "bzznetworkid",
|
||||||
Usage: "Network identifier (integer, default 3=swarm testnet)",
|
Usage: "Network identifier (integer, default 3=swarm testnet)",
|
||||||
// defining this here means we can't distinguish if it was passed at cmd line or system default when deciding to use saved values from config
|
|
||||||
//Value: network.NetworkId,
|
|
||||||
}
|
}
|
||||||
SwarmConfigPathFlag = cli.StringFlag{
|
SwarmConfigPathFlag = cli.StringFlag{
|
||||||
Name: "bzzconfig",
|
Name: "bzzconfig",
|
||||||
|
|
@ -238,7 +236,7 @@ func bzzd(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerBzzService(ctx *cli.Context, stack *node.Node) {
|
func registerBzzService(ctx *cli.Context, stack *node.Node) {
|
||||||
|
|
||||||
prvkey := getAccount(ctx, stack)
|
prvkey := getAccount(ctx, stack)
|
||||||
|
|
||||||
chbookaddr := common.HexToAddress(ctx.GlobalString(ChequebookAddrFlag.Name))
|
chbookaddr := common.HexToAddress(ctx.GlobalString(ChequebookAddrFlag.Name))
|
||||||
|
|
@ -246,7 +244,7 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
|
||||||
if bzzdir == "" {
|
if bzzdir == "" {
|
||||||
bzzdir = stack.InstanceDir()
|
bzzdir = stack.InstanceDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
bzzconfig, err := bzzapi.NewConfig(bzzdir, chbookaddr, prvkey, ctx.GlobalUint64(SwarmNetworkIdFlag.Name))
|
bzzconfig, err := bzzapi.NewConfig(bzzdir, chbookaddr, prvkey, ctx.GlobalUint64(SwarmNetworkIdFlag.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("unable to configure swarm: %v", err)
|
utils.Fatalf("unable to configure swarm: %v", err)
|
||||||
|
|
@ -277,7 +275,7 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
|
||||||
|
|
||||||
func getAccount(ctx *cli.Context, stack *node.Node) *ecdsa.PrivateKey {
|
func getAccount(ctx *cli.Context, stack *node.Node) *ecdsa.PrivateKey {
|
||||||
keyid := ctx.GlobalString(SwarmAccountFlag.Name)
|
keyid := ctx.GlobalString(SwarmAccountFlag.Name)
|
||||||
|
|
||||||
if keyid == "" {
|
if keyid == "" {
|
||||||
utils.Fatalf("Option %q is required", SwarmAccountFlag.Name)
|
utils.Fatalf("Option %q is required", SwarmAccountFlag.Name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
|
||||||
pubkey := crypto.FromECDSAPub(&prvKey.PublicKey)
|
pubkey := crypto.FromECDSAPub(&prvKey.PublicKey)
|
||||||
pubkeyhex := common.ToHex(pubkey)
|
pubkeyhex := common.ToHex(pubkey)
|
||||||
keyhex := crypto.Sha3Hash(pubkey).Hex()
|
keyhex := crypto.Sha3Hash(pubkey).Hex()
|
||||||
|
|
||||||
self = &Config{
|
self = &Config{
|
||||||
SyncParams: network.NewSyncParams(dirpath),
|
SyncParams: network.NewSyncParams(dirpath),
|
||||||
HiveParams: network.NewHiveParams(dirpath),
|
HiveParams: network.NewHiveParams(dirpath),
|
||||||
|
|
@ -89,12 +89,12 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
|
||||||
if networkId == 0 {
|
if networkId == 0 {
|
||||||
self.NetworkId = network.NetworkId
|
self.NetworkId = network.NetworkId
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// file does not exist
|
// file does not exist
|
||||||
// write out config file
|
// write out config file
|
||||||
err = self.Save()
|
err = self.Save()
|
||||||
|
|
@ -103,7 +103,7 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// file exists, deserialise
|
// file exists, deserialise
|
||||||
err = json.Unmarshal(data, self)
|
err = json.Unmarshal(data, self)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -116,13 +116,13 @@ func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey, n
|
||||||
if keyhex != self.BzzKey {
|
if keyhex != self.BzzKey {
|
||||||
return nil, fmt.Errorf("bzz key does not match the one in the config file %v != %v", keyhex, self.BzzKey)
|
return nil, fmt.Errorf("bzz key does not match the one in the config file %v != %v", keyhex, self.BzzKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if networkId != 0 {
|
if networkId != 0 {
|
||||||
self.NetworkId = networkId
|
self.NetworkId = networkId
|
||||||
}
|
}
|
||||||
|
|
||||||
self.Swap.SetKey(prvKey)
|
self.Swap.SetKey(prvKey)
|
||||||
|
|
||||||
if (self.EnsRoot == common.Address{}) {
|
if (self.EnsRoot == common.Address{}) {
|
||||||
self.EnsRoot = ensRootAddress
|
self.EnsRoot = ensRootAddress
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue