p2p: traces

This commit is contained in:
Anton Evangelatov 2019-01-18 14:35:21 +01:00
parent 2131b622ad
commit 1a02c4c091

View file

@ -166,6 +166,7 @@ func (s *dialstate) newTasks(nRunning int, peers map[enode.ID]*Peer, now time.Ti
var newtasks []task var newtasks []task
addDial := func(flag connFlag, n *enode.Node) bool { addDial := func(flag connFlag, n *enode.Node) bool {
log.Trace("addDial func", n.ID())
if err := s.checkDial(n, peers); err != nil { if err := s.checkDial(n, peers); err != nil {
log.Trace("Skipping dial candidate", "id", n.ID(), "addr", &net.TCPAddr{IP: n.IP(), Port: n.TCP()}, "err", err) log.Trace("Skipping dial candidate", "id", n.ID(), "addr", &net.TCPAddr{IP: n.IP(), Port: n.TCP()}, "err", err)
return false return false
@ -206,13 +207,17 @@ func (s *dialstate) newTasks(nRunning int, peers map[enode.ID]*Peer, now time.Ti
// If we don't have any peers whatsoever, try to dial a random bootnode. This // If we don't have any peers whatsoever, try to dial a random bootnode. This
// scenario is useful for the testnet (and private networks) where the discovery // scenario is useful for the testnet (and private networks) where the discovery
// table might be full of mostly bad peers, making it hard to find good ones. // table might be full of mostly bad peers, making it hard to find good ones.
log.Trace("before if", "len(s.bootnodes)", len(s.bootnodes), "needdyndials", needDynDials, "bool", now.Sub(s.start) > fallbackInterval)
if len(peers) == 0 && len(s.bootnodes) > 0 && needDynDials > 0 && now.Sub(s.start) > fallbackInterval { if len(peers) == 0 && len(s.bootnodes) > 0 && needDynDials > 0 && now.Sub(s.start) > fallbackInterval {
bootnode := s.bootnodes[0] bootnode := s.bootnodes[0]
s.bootnodes = append(s.bootnodes[:0], s.bootnodes[1:]...) s.bootnodes = append(s.bootnodes[:0], s.bootnodes[1:]...)
s.bootnodes = append(s.bootnodes, bootnode) s.bootnodes = append(s.bootnodes, bootnode)
log.Trace("inside if", "bootnode", bootnode, "len(s.bootnodes)", len(s.bootnodes))
if addDial(dynDialedConn, bootnode) { if addDial(dynDialedConn, bootnode) {
needDynDials-- needDynDials--
log.Trace("inside addDial if", "needDynDials", needDynDials)
} }
} }
// Use random nodes from the table for half of the necessary // Use random nodes from the table for half of the necessary
@ -261,6 +266,7 @@ var (
) )
func (s *dialstate) checkDial(n *enode.Node, peers map[enode.ID]*Peer) error { func (s *dialstate) checkDial(n *enode.Node, peers map[enode.ID]*Peer) error {
log.Trace("checkDial func", n.ID())
_, dialing := s.dialing[n.ID()] _, dialing := s.dialing[n.ID()]
switch { switch {
case dialing: case dialing: