Skip to content

Commit

Permalink
PrintPeers
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozen committed Jul 23, 2024
1 parent 55f05e1 commit 19ff073
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions node/node_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 19ff073

Please sign in to comment.