mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
swarm: enable both bzz and hive
This commit is contained in:
parent
314a180116
commit
2131b622ad
2 changed files with 15 additions and 15 deletions
|
|
@ -67,6 +67,7 @@ type BzzConfig struct {
|
||||||
HiveParams *HiveParams
|
HiveParams *HiveParams
|
||||||
NetworkID uint64
|
NetworkID uint64
|
||||||
LightNode bool
|
LightNode bool
|
||||||
|
BootnodeMode bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bzz is the swarm protocol bundle
|
// Bzz is the swarm protocol bundle
|
||||||
|
|
@ -87,7 +88,7 @@ type Bzz struct {
|
||||||
// * overlay driver
|
// * overlay driver
|
||||||
// * peer store
|
// * peer store
|
||||||
func NewBzz(config *BzzConfig, kad *Kademlia, store state.Store, streamerSpec *protocols.Spec, streamerRun func(*BzzPeer) error) *Bzz {
|
func NewBzz(config *BzzConfig, kad *Kademlia, store state.Store, streamerSpec *protocols.Spec, streamerRun func(*BzzPeer) error) *Bzz {
|
||||||
return &Bzz{
|
bzz := &Bzz{
|
||||||
Hive: NewHive(config.HiveParams, kad, store),
|
Hive: NewHive(config.HiveParams, kad, store),
|
||||||
NetworkID: config.NetworkID,
|
NetworkID: config.NetworkID,
|
||||||
LightNode: config.LightNode,
|
LightNode: config.LightNode,
|
||||||
|
|
@ -96,6 +97,13 @@ func NewBzz(config *BzzConfig, kad *Kademlia, store state.Store, streamerSpec *p
|
||||||
streamerRun: streamerRun,
|
streamerRun: streamerRun,
|
||||||
streamerSpec: streamerSpec,
|
streamerSpec: streamerSpec,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.BootnodeMode {
|
||||||
|
bzz.streamerRun = nil
|
||||||
|
bzz.streamerSpec = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return bzz
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateLocalAddr updates underlayaddress of the running node
|
// UpdateLocalAddr updates underlayaddress of the running node
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,11 @@ func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err e
|
||||||
config.HiveParams.Discovery = true
|
config.HiveParams.Discovery = true
|
||||||
|
|
||||||
bzzconfig := &network.BzzConfig{
|
bzzconfig := &network.BzzConfig{
|
||||||
NetworkID: config.NetworkID,
|
NetworkID: config.NetworkID,
|
||||||
OverlayAddr: common.FromHex(config.BzzKey),
|
OverlayAddr: common.FromHex(config.BzzKey),
|
||||||
HiveParams: config.HiveParams,
|
HiveParams: config.HiveParams,
|
||||||
LightNode: config.LightNodeEnabled,
|
LightNode: config.LightNodeEnabled,
|
||||||
|
BootnodeMode: config.BootnodeMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.stateStore, err = state.NewDBStore(filepath.Join(config.Path, "state-store.db"))
|
self.stateStore, err = state.NewDBStore(filepath.Join(config.Path, "state-store.db"))
|
||||||
|
|
@ -457,16 +458,7 @@ func (self *Swarm) Stop() error {
|
||||||
// Protocols implements the node.Service interface
|
// Protocols implements the node.Service interface
|
||||||
func (s *Swarm) Protocols() (protos []p2p.Protocol) {
|
func (s *Swarm) Protocols() (protos []p2p.Protocol) {
|
||||||
if s.config.BootnodeMode {
|
if s.config.BootnodeMode {
|
||||||
protos = []p2p.Protocol{
|
protos = append(protos, s.bzz.Protocols()...)
|
||||||
{
|
|
||||||
Name: network.DiscoverySpec.Name,
|
|
||||||
Version: network.DiscoverySpec.Version,
|
|
||||||
Length: network.DiscoverySpec.Length(),
|
|
||||||
Run: s.bzz.RunProtocol(network.DiscoverySpec, s.bzz.Hive.Run),
|
|
||||||
NodeInfo: s.bzz.Hive.NodeInfo,
|
|
||||||
PeerInfo: s.bzz.Hive.PeerInfo,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
protos = append(protos, s.bzz.Protocols()...)
|
protos = append(protos, s.bzz.Protocols()...)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue