Skip to content

Commit

Permalink
healthcheck: log peer address info
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed Mar 28, 2024
1 parent 029aa7f commit 1e79184
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fly/cmd/healthcheck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

ipfslog "github.com/ipfs/go-log/v2"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/peer"
"go.uber.org/zap"
"google.golang.org/protobuf/proto"
)
Expand Down Expand Up @@ -68,6 +69,7 @@ func main() {
localContext, localCancel := context.WithCancel(rootCtx)
defer localCancel()
hbReceived := false
var addrInfo peer.AddrInfo
observationsReceived := 0
components := p2p.DefaultComponents()
components.Port = p2pPort
Expand Down Expand Up @@ -108,8 +110,11 @@ func main() {
switch m := msg.Message.(type) {
case *gossipv1.GossipMessage_SignedHeartbeat:
logger.Debug("received heartbeat")
if !hbReceived && bytes.Equal(m.SignedHeartbeat.GuardianAddr, guardianPubKey) {
hbReceived = true
if bytes.Equal(m.SignedHeartbeat.GuardianAddr, guardianPubKey) {
addrInfo = host.Peerstore().PeerInfo(envelope.GetFrom())
if !hbReceived {
hbReceived = true
}
}
case *gossipv1.GossipMessage_SignedObservation:
logger.Debug("received observation")
Expand All @@ -135,7 +140,7 @@ func main() {
logger.Info("local context cancelled")

if hbReceived {
fmt.Println("✅ guardian heartbeat received")
fmt.Println("✅ guardian heartbeat received", addrInfo.String())
} else {
fmt.Println("❌ NO HEARTBEAT RECEIVED")
}
Expand Down

0 comments on commit 1e79184

Please sign in to comment.