aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/swarm.go
diff options
context:
space:
mode:
authorAnton Evangelatov <anton.evangelatov@gmail.com>2019-01-24 19:02:18 +0800
committerRafael Matias <rafael@skyle.net>2019-02-19 19:56:30 +0800
commit4976fcc91a43b5c7047c51a03985887b694f0fbb (patch)
treec2aef8ce616498f44d38a6a830c211112e0a6d71 /swarm/swarm.go
parent878aa58ec66ffc541a80aa65ee35261efa086c9c (diff)
downloaddexon-4976fcc91a43b5c7047c51a03985887b694f0fbb.tar.gz
dexon-4976fcc91a43b5c7047c51a03985887b694f0fbb.tar.zst
dexon-4976fcc91a43b5c7047c51a03985887b694f0fbb.zip
swarm: bootnode-mode, new bootnodes and no p2p package discovery (#18498)
(cherry picked from commit bbd120354a8d226b446591eeda9f9462cb9b690a)
Diffstat (limited to 'swarm/swarm.go')
-rw-r--r--swarm/swarm.go26
1 files changed, 15 insertions, 11 deletions
diff --git a/swarm/swarm.go b/swarm/swarm.go
index db52675fd..d17d81320 100644
--- a/swarm/swarm.go
+++ b/swarm/swarm.go
@@ -84,12 +84,11 @@ type Swarm struct {
tracerClose io.Closer
}
-// creates a new swarm service instance
+// NewSwarm creates a new swarm service instance
// implements node.Service
// If mockStore is not nil, it will be used as the storage for chunk data.
// MockStore should be used only for testing.
func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err error) {
-
if bytes.Equal(common.FromHex(config.PublicKey), storage.ZeroAddr) {
return nil, fmt.Errorf("empty public key")
}
@@ -116,10 +115,11 @@ func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err e
config.HiveParams.Discovery = true
bzzconfig := &network.BzzConfig{
- NetworkID: config.NetworkID,
- OverlayAddr: common.FromHex(config.BzzKey),
- HiveParams: config.HiveParams,
- LightNode: config.LightNodeEnabled,
+ NetworkID: config.NetworkID,
+ OverlayAddr: common.FromHex(config.BzzKey),
+ HiveParams: config.HiveParams,
+ LightNode: config.LightNodeEnabled,
+ BootnodeMode: config.BootnodeMode,
}
self.stateStore, err = state.NewDBStore(filepath.Join(config.Path, "state-store.db"))
@@ -455,12 +455,16 @@ func (self *Swarm) Stop() error {
return err
}
-// implements the node.Service interface
-func (self *Swarm) Protocols() (protos []p2p.Protocol) {
- protos = append(protos, self.bzz.Protocols()...)
+// Protocols implements the node.Service interface
+func (s *Swarm) Protocols() (protos []p2p.Protocol) {
+ if s.config.BootnodeMode {
+ protos = append(protos, s.bzz.Protocols()...)
+ } else {
+ protos = append(protos, s.bzz.Protocols()...)
- if self.ps != nil {
- protos = append(protos, self.ps.Protocols()...)
+ if s.ps != nil {
+ protos = append(protos, s.ps.Protocols()...)
+ }
}
return
}