diff --git a/p2p/dial.go b/p2p/dial.go index ce1a6e4ebd28bbae9d5d44c01e41b78ad13ba6fb..79358082b9545a811b605330083b060fb0179319 100644 --- a/p2p/dial.go +++ b/p2p/dial.go @@ -42,7 +42,7 @@ const ( dialHistoryExpiration = inboundThrottleTime + 5*time.Second // Config for the "Looking for peers" message. - dialStatsLogInterval = 60 * time.Second // printed at most this often + dialStatsLogInterval = 10 * time.Second // printed at most this often dialStatsPeerLimit = 20 // but not if more than this many dialed peers // Endpoint resolution is throttled with bounded backoff. @@ -247,7 +247,7 @@ loop: nodesCh = nil } d.rearmHistoryTimer(historyExp) - d.logStats() + //d.logStats() select { case <-d.ctx.Done(): @@ -341,13 +341,16 @@ func (d *dialScheduler) readNodes(it enode.Iterator) { // logStats prints dialer statistics to the log. The message is suppressed when enough // peers are connected because users should only see it while their client is starting up // or comes back online. -func (d *dialScheduler) logStats() { +func (d *dialScheduler) logStats(activePeerCount, maxActivePeers int) { now := d.clock.Now() if d.lastStatsLog.Add(dialStatsLogInterval) > now { return } if d.dialPeers < dialStatsPeerLimit && d.dialPeers < d.maxDialPeers { - d.log.Info("[p2p] Looking for peers", "protocol", d.subProtocolVersion, "peers", fmt.Sprintf("%d/%d", len(d.peers), d.maxDialPeers), "tried", d.doneSinceLastLog, "static", len(d.static)) + active := fmt.Sprintf("%d/%d", activePeerCount, maxActivePeers) + connected := fmt.Sprintf("%d/%d", len(d.peers), d.maxDialPeers) + fmt.Printf("aa: %d,%d\n", d.maxActiveDials, d.dialPeers) + d.log.Info("[p2p] Peers", "protocol", d.subProtocolVersion, "activePeers", active, "connected", connected, "static", len(d.static), "tried", d.doneSinceLastLog) } d.doneSinceLastLog = 0 d.lastStatsLog = now diff --git a/p2p/server.go b/p2p/server.go index 3883f763e608a69dfcb6d68e0e8f1e18c4156596..63ff712e2d4a6d2a27be7119a01d03382e0528b2 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -741,6 +741,8 @@ func (srv *Server) run() { for _, n := range srv.TrustedNodes { trusted[n.ID()] = true } + logEvery := time.NewTicker(10 * time.Second) + defer logEvery.Stop() running: for { @@ -748,7 +750,9 @@ running: case <-srv.quit: // The server was stopped. Run the cleanup logic. break running - + case <-logEvery.C: + fmt.Printf("inbound: %d/%d\n", inboundCount, srv.maxInboundConns()) + srv.dialsched.logStats(len(peers), srv.MaxPeers) case n := <-srv.addtrusted: // This channel is used by AddTrustedPeer to add a node // to the trusted node set.