Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dan/dns peer count logs #416

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion cmd/p2p/sensor/sensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ var SensorCmd = &cobra.Command{
}

go handleAPI(&server, msgCounter)

// Periodically check the peer count
go checkPeerCount(&server)

// Run DNS discovery immediately at startup.
go handleDNSDiscovery(&server)
Expand Down Expand Up @@ -390,6 +393,21 @@ func handleAPI(server *ethp2p.Server, counter *prometheus.CounterVec) {
}
}

func checkPeerCount(server *ethp2p.Server) {
for {
// Get the current number of peers
peerCount := server.Peers()

// Log the current peer count
log.Info().
Int("peer_count", len(peerCount)).
Msg("Current number of peers")

// Sleep for 30 seconds before checking again
time.Sleep(30 * time.Second)
}
}

// handleDNSDiscovery performs DNS-based peer discovery and adds new peers to
// the p2p server. It syncs the DNS discovery tree and adds any newly discovered
// peers not already in the peers map.
Expand Down Expand Up @@ -534,7 +552,7 @@ func init() {
log.Error().Err(err).Msg("Failed to mark sensor-id as required persistent flag")
}
SensorCmd.Flags().IntVarP(&inputSensorParams.MaxPeers, "max-peers", "m", 2000, "Maximum number of peers to connect to")
SensorCmd.Flags().IntVarP(&inputSensorParams.MaxDatabaseConcurrency, "max-db-concurrency", "D", 10000,
SensorCmd.Flags().IntVarP(&inputSensorParams.MaxDatabaseConcurrency, "max-db-concurrency", "D", 20000,
`Maximum number of concurrent database operations to perform. Increasing this
will result in less chance of missing data (i.e. broken pipes) but can
significantly increase memory usage.`)
Expand Down
2 changes: 1 addition & 1 deletion doc/polycli_p2p_sensor.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ If no nodes.json file exists, it will be created.
-k, --key-file string Private key file (cannot be set with --key)
-D, --max-db-concurrency int Maximum number of concurrent database operations to perform. Increasing this
will result in less chance of missing data (i.e. broken pipes) but can
significantly increase memory usage. (default 10000)
significantly increase memory usage. (default 20000)
-m, --max-peers int Maximum number of peers to connect to (default 2000)
--nat string NAT port mapping mechanism (any|none|upnp|pmp|pmp:<IP>|extip:<IP>) (default "any")
-n, --network-id uint Filter discovered nodes by this network ID
Expand Down
Loading