From edceca8f2d40c24ee5fa9f0f167a281e269102ac Mon Sep 17 00:00:00 2001 From: frozen <355847+Frozen@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:14:57 -0400 Subject: [PATCH] PrintPeers --- node/node_handler.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/node/node_handler.go b/node/node_handler.go index 7aa87100bb..373c9cad35 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -418,6 +418,7 @@ func IsRunningBeaconChain(c *consensus.Consensus) bool { // BootstrapConsensus is a goroutine to check number of peers and start the consensus func (node *Node) BootstrapConsensus() error { + go node.PrintPeers() ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() min := node.Consensus.MinPeers @@ -452,3 +453,12 @@ func (node *Node) BootstrapConsensus() error { return nil } } + +func (node *Node) PrintPeers() { + for { + <-time.After(5 * time.Second) + known := node.host.GetPeerCount() + connected := len(node.host.Network().Peers()) + fmt.Printf("connected %d, known %d\n", connected, known) + } +}