Skip to content

Commit 1e79184

Browse files
committed
healthcheck: log peer address info
1 parent 029aa7f commit 1e79184

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fly/cmd/healthcheck/main.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
ipfslog "github.com/ipfs/go-log/v2"
2020
pubsub "github.com/libp2p/go-libp2p-pubsub"
21+
"github.com/libp2p/go-libp2p/core/peer"
2122
"go.uber.org/zap"
2223
"google.golang.org/protobuf/proto"
2324
)
@@ -68,6 +69,7 @@ func main() {
6869
localContext, localCancel := context.WithCancel(rootCtx)
6970
defer localCancel()
7071
hbReceived := false
72+
var addrInfo peer.AddrInfo
7173
observationsReceived := 0
7274
components := p2p.DefaultComponents()
7375
components.Port = p2pPort
@@ -108,8 +110,11 @@ func main() {
108110
switch m := msg.Message.(type) {
109111
case *gossipv1.GossipMessage_SignedHeartbeat:
110112
logger.Debug("received heartbeat")
111-
if !hbReceived && bytes.Equal(m.SignedHeartbeat.GuardianAddr, guardianPubKey) {
112-
hbReceived = true
113+
if bytes.Equal(m.SignedHeartbeat.GuardianAddr, guardianPubKey) {
114+
addrInfo = host.Peerstore().PeerInfo(envelope.GetFrom())
115+
if !hbReceived {
116+
hbReceived = true
117+
}
113118
}
114119
case *gossipv1.GossipMessage_SignedObservation:
115120
logger.Debug("received observation")
@@ -135,7 +140,7 @@ func main() {
135140
logger.Info("local context cancelled")
136141

137142
if hbReceived {
138-
fmt.Println("✅ guardian heartbeat received")
143+
fmt.Println("✅ guardian heartbeat received", addrInfo.String())
139144
} else {
140145
fmt.Println("❌ NO HEARTBEAT RECEIVED")
141146
}

0 commit comments

Comments
 (0)