diff options
author | Anton Evangelatov <anton.evangelatov@gmail.com> | 2019-01-24 19:02:18 +0800 |
---|---|---|
committer | Rafael Matias <rafael@skyle.net> | 2019-02-19 19:56:30 +0800 |
commit | 4976fcc91a43b5c7047c51a03985887b694f0fbb (patch) | |
tree | c2aef8ce616498f44d38a6a830c211112e0a6d71 /cmd/swarm/main.go | |
parent | 878aa58ec66ffc541a80aa65ee35261efa086c9c (diff) | |
download | go-tangerine-4976fcc91a43b5c7047c51a03985887b694f0fbb.tar go-tangerine-4976fcc91a43b5c7047c51a03985887b694f0fbb.tar.gz go-tangerine-4976fcc91a43b5c7047c51a03985887b694f0fbb.tar.bz2 go-tangerine-4976fcc91a43b5c7047c51a03985887b694f0fbb.tar.lz go-tangerine-4976fcc91a43b5c7047c51a03985887b694f0fbb.tar.xz go-tangerine-4976fcc91a43b5c7047c51a03985887b694f0fbb.tar.zst go-tangerine-4976fcc91a43b5c7047c51a03985887b694f0fbb.zip |
swarm: bootnode-mode, new bootnodes and no p2p package discovery (#18498)
(cherry picked from commit bbd120354a8d226b446591eeda9f9462cb9b690a)
Diffstat (limited to 'cmd/swarm/main.go')
-rw-r--r-- | cmd/swarm/main.go | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index ccbb24eec..722dc4ff5 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -154,7 +154,6 @@ func init() { utils.BootnodesFlag, utils.KeyStoreDirFlag, utils.ListenPortFlag, - utils.NoDiscoverFlag, utils.DiscoveryV5Flag, utils.NetrestrictFlag, utils.NodeKeyFileFlag, @@ -187,6 +186,8 @@ func init() { SwarmUploadDefaultPath, SwarmUpFromStdinFlag, SwarmUploadMimeType, + // bootnode mode + SwarmBootnodeModeFlag, // storage flags SwarmStorePath, SwarmStoreCapacity, @@ -227,12 +228,17 @@ func main() { func keys(ctx *cli.Context) error { privateKey := getPrivKey(ctx) - pub := hex.EncodeToString(crypto.FromECDSAPub(&privateKey.PublicKey)) + pubkey := crypto.FromECDSAPub(&privateKey.PublicKey) + pubkeyhex := hex.EncodeToString(pubkey) pubCompressed := hex.EncodeToString(crypto.CompressPubkey(&privateKey.PublicKey)) + bzzkey := crypto.Keccak256Hash(pubkey).Hex() + if !ctx.Bool(SwarmCompressedFlag.Name) { - fmt.Println(fmt.Sprintf("publicKey=%s", pub)) + fmt.Println(fmt.Sprintf("bzzkey=%s", bzzkey[2:])) + fmt.Println(fmt.Sprintf("publicKey=%s", pubkeyhex)) } fmt.Println(fmt.Sprintf("publicKeyCompressed=%s", pubCompressed)) + return nil } @@ -272,6 +278,10 @@ func bzzd(ctx *cli.Context) error { setSwarmBootstrapNodes(ctx, &cfg) //setup the ethereum node utils.SetNodeConfig(ctx, &cfg) + + //always disable discovery from p2p package - swarm discovery is done with the `hive` protocol + cfg.P2P.NoDiscovery = true + stack, err := node.New(&cfg) if err != nil { utils.Fatalf("can't create node: %v", err) @@ -294,6 +304,15 @@ func bzzd(ctx *cli.Context) error { stack.Stop() }() + // add swarm bootnodes, because swarm doesn't use p2p package's discovery discv5 + go func() { + s := stack.Server() + + for _, n := range cfg.P2P.BootstrapNodes { + s.AddPeer(n) + } + }() + stack.Wait() return nil } |