fix: enable bandwidth stats depending on node config setting

This commit is contained in:
Richard Ramos 2021-09-29 10:52:45 -04:00
parent cee18efd71
commit 0fc8c036b1
2 changed files with 8 additions and 1 deletions

View File

@ -597,6 +597,9 @@ type ShhextConfig struct {
// AnonMetricsServerPostgresURI is the uri used to connect to a postgres db // AnonMetricsServerPostgresURI is the uri used to connect to a postgres db
AnonMetricsServerPostgresURI string AnonMetricsServerPostgresURI string
// BandwidthStatsEnabled indicates if a signal is going to be emitted to indicate the upload and download rate
BandwidthStatsEnabled bool
} }
// Validate validates the ShhextConfig struct and returns an error if inconsistent values are found // Validate validates the ShhextConfig struct and returns an error if inconsistent values are found

View File

@ -164,7 +164,11 @@ func (s *Service) StartMessenger() (*protocol.MessengerResponse, error) {
} }
go s.retrieveMessagesLoop(time.Second, s.cancelMessenger) go s.retrieveMessagesLoop(time.Second, s.cancelMessenger)
go s.verifyTransactionLoop(30*time.Second, s.cancelMessenger) go s.verifyTransactionLoop(30*time.Second, s.cancelMessenger)
go s.retrieveStats(5*time.Second, s.cancelMessenger)
if s.config.BandwidthStatsEnabled {
go s.retrieveStats(5*time.Second, s.cancelMessenger)
}
return response, nil return response, nil
} }