4141#include < map>
4242#include < memory>
4343#include < set>
44+ #include < sstream>
4445
4546namespace ripple {
4647namespace PeerFinder {
@@ -492,15 +493,21 @@ class Logic
492493 std::vector<beast::IP::Endpoint>
493494 autoconnect ()
494495 {
496+ std::stringstream ss;
497+ ss << " AUTOCONNECT " ;
495498 std::vector<beast::IP::Endpoint> const none;
496499
497500 std::lock_guard _ (lock_);
498501
499502 // Count how many more outbound attempts to make
500503 //
501504 auto needed (counts_.attempts_needed ());
502- if (needed == 0 )
505+ if (needed == 0 ) {
506+ ss << " 0 attempts needed, returning none" ;
507+ JLOG (m_journal.debug ()) << ss.str ();
503508 return none;
509+ }
510+ ss << " attempts needed: " << needed << " . " ;
504511
505512 ConnectHandouts h (needed, m_squelches);
506513
@@ -524,8 +531,9 @@ class Logic
524531
525532 if (!h.list ().empty ())
526533 {
527- JLOG (m_journal.debug ()) << beast::leftw (18 ) << " Logic connect "
528- << h.list ().size () << " fixed" ;
534+ // JLOG(m_journal.debug()) << beast::leftw(18) << "Logic connect "
535+ ss << " returning Logic connect " << h.list ().size () << " fixed" ;
536+ JLOG (m_journal.debug ()) << ss.str ();
529537 return h.list ();
530538 }
531539
@@ -534,15 +542,21 @@ class Logic
534542 JLOG (m_journal.debug ())
535543 << beast::leftw (18 ) << " Logic waiting on "
536544 << counts_.attempts () << " attempts" ;
545+ ss << " returning none, pending outbound attempts " << counts_.attempts ();
546+ JLOG (m_journal.debug ()) << ss.str ();
537547 return none;
538548 }
539549 }
540550
541551 // Only proceed if auto connect is enabled and we
542552 // have less than the desired number of outbound slots
543553 //
544- if (!config_.autoConnect || counts_.out_active () >= counts_.out_max ())
554+ if (!config_.autoConnect || counts_.out_active () >= counts_.out_max ()) {
555+ ss << " returning none based on autoConnect || out_active >= out_max: "
556+ << config_.autoConnect << ' ,' << counts_.out_active () << ' ,' << counts_.out_max ();
557+ JLOG (m_journal.debug ()) << ss.str ();
545558 return none;
559+ }
546560
547561 // 2. Use Livecache if:
548562 // There are any entries in the cache OR
@@ -554,17 +568,21 @@ class Logic
554568 &h, (&h) + 1 , livecache_.hops .rbegin (), livecache_.hops .rend ());
555569 if (!h.list ().empty ())
556570 {
557- JLOG (m_journal.debug ())
558- << beast::leftw (18 ) << " Logic connect " << h.list ().size ()
571+ // JLOG(m_journal.debug())
572+ ss
573+ << " returning Logic connect " << h.list ().size ()
559574 << " live "
560575 << ((h.list ().size () > 1 ) ? " endpoints" : " endpoint" );
576+ JLOG (m_journal.debug ()) << ss.str ();
561577 return h.list ();
562578 }
563579 else if (counts_.attempts () > 0 )
564580 {
565- JLOG (m_journal.debug ())
566- << beast::leftw (18 ) << " Logic waiting on "
581+ // JLOG(m_journal.debug())
582+ ss
583+ << " returning none, Logic waiting on "
567584 << counts_.attempts () << " attempts" ;
585+ JLOG (m_journal.debug ()) << ss.str ();
568586 return none;
569587 }
570588 }
@@ -592,14 +610,18 @@ class Logic
592610
593611 if (!h.list ().empty ())
594612 {
595- JLOG (m_journal.debug ())
596- << beast::leftw (18 ) << " Logic connect " << h.list ().size ()
613+ // JLOG(m_journal.debug())
614+ ss
615+ << " returning Logic connect " << h.list ().size ()
597616 << " boot "
598617 << ((h.list ().size () > 1 ) ? " addresses" : " address" );
618+ JLOG (m_journal.debug ()) << ss.str ();
599619 return h.list ();
600620 }
601621
602622 // If we get here we are stuck
623+ ss << " returning none, we are stuck" ;
624+ JLOG (m_journal.debug ()) << ss.str ();
603625 return none;
604626 }
605627
0 commit comments