fix: only use discv5 functions if enabled
This commit is contained in:
parent
002cb10847
commit
2f49117061
|
@ -90,6 +90,7 @@ type settings struct {
|
||||||
PeerExchange bool // Enable peer exchange
|
PeerExchange bool // Enable peer exchange
|
||||||
DiscoveryLimit int // Indicates the number of nodes to discover
|
DiscoveryLimit int // Indicates the number of nodes to discover
|
||||||
Nameserver string // Optional nameserver to use for dns discovery
|
Nameserver string // Optional nameserver to use for dns discovery
|
||||||
|
EnableDiscV5 bool // Indicates whether discv5 is enabled or not
|
||||||
}
|
}
|
||||||
|
|
||||||
// Waku represents a dark communication interface through the Ethereum
|
// Waku represents a dark communication interface through the Ethereum
|
||||||
|
@ -218,6 +219,7 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
|
||||||
PeerExchange: cfg.PeerExchange,
|
PeerExchange: cfg.PeerExchange,
|
||||||
DiscoveryLimit: cfg.DiscoveryLimit,
|
DiscoveryLimit: cfg.DiscoveryLimit,
|
||||||
Nameserver: cfg.Nameserver,
|
Nameserver: cfg.Nameserver,
|
||||||
|
EnableDiscV5: cfg.EnableDiscV5,
|
||||||
}
|
}
|
||||||
|
|
||||||
waku.filters = common.NewFilters()
|
waku.filters = common.NewFilters()
|
||||||
|
@ -351,6 +353,7 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
|
||||||
waku.connStatusMu.Unlock()
|
waku.connStatusMu.Unlock()
|
||||||
signal.SendPeerStats(latestConnStatus)
|
signal.SendPeerStats(latestConnStatus)
|
||||||
|
|
||||||
|
if cfg.EnableDiscV5 {
|
||||||
// Restarting DiscV5
|
// Restarting DiscV5
|
||||||
if !latestConnStatus.IsOnline && isConnected {
|
if !latestConnStatus.IsOnline && isConnected {
|
||||||
waku.logger.Debug("Restarting DiscV5: offline and is connected")
|
waku.logger.Debug("Restarting DiscV5: offline and is connected")
|
||||||
|
@ -368,6 +371,7 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go waku.telemetryBandwidthStats(cfg.TelemetryServerURL)
|
go waku.telemetryBandwidthStats(cfg.TelemetryServerURL)
|
||||||
|
@ -1406,6 +1410,10 @@ func (w *Waku) ConnectionChanged(state connection.State) {
|
||||||
// It backs off exponentially until maxRetries, at which point it restarts from 0
|
// It backs off exponentially until maxRetries, at which point it restarts from 0
|
||||||
// It also restarts if there's a connection change signalled from the client
|
// It also restarts if there's a connection change signalled from the client
|
||||||
func (w *Waku) seedBootnodesForDiscV5() {
|
func (w *Waku) seedBootnodesForDiscV5() {
|
||||||
|
if !w.settings.EnableDiscV5 || w.node.DiscV5() == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ticker := time.NewTicker(200 * time.Millisecond)
|
ticker := time.NewTicker(200 * time.Millisecond)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
var lastTry = time.Now().UnixNano() / int64(time.Millisecond)
|
var lastTry = time.Now().UnixNano() / int64(time.Millisecond)
|
||||||
|
|
Loading…
Reference in New Issue