Skip to content

Commit 7bcc29f

Browse files
committed
Add debug logging for p2p
1 parent 62888e3 commit 7bcc29f

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

services/p2p_client/client.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,38 @@ func (c *Client) consume(ctx context.Context, msgs <-chan teranodep2p.NodeStatus
205205
func (c *Client) handleNodeStatus(ctx context.Context, msg teranodep2p.NodeStatusMessage) {
206206
metrics.P2PNodeStatusMessagesTotal.Inc()
207207

208+
if ce := c.logger.Check(zap.DebugLevel, "received node_status"); ce != nil {
209+
fields := []zap.Field{
210+
zap.String("peer_id", msg.PeerID),
211+
zap.String("client_name", msg.ClientName),
212+
zap.String("type", msg.Type),
213+
zap.String("base_url", msg.BaseURL),
214+
zap.String("propagation_url", msg.PropagationURL),
215+
zap.String("version", msg.Version),
216+
zap.String("commit_hash", msg.CommitHash),
217+
zap.String("best_block_hash", msg.BestBlockHash),
218+
zap.Uint32("best_height", msg.BestHeight),
219+
zap.Uint64("tx_count", msg.TxCount),
220+
zap.Uint32("subtree_count", msg.SubtreeCount),
221+
zap.String("fsm_state", msg.FSMState),
222+
zap.Int64("start_time", msg.StartTime),
223+
zap.Float64("uptime_seconds", msg.Uptime),
224+
zap.String("miner_name", msg.MinerName),
225+
zap.String("listen_mode", msg.ListenMode),
226+
zap.String("chain_work", msg.ChainWork),
227+
zap.String("sync_peer_id", msg.SyncPeerID),
228+
zap.Uint32("sync_peer_height", msg.SyncPeerHeight),
229+
zap.String("sync_peer_block_hash", msg.SyncPeerBlockHash),
230+
zap.Int64("sync_connected_at", msg.SyncConnectedAt),
231+
zap.Int("connected_peers_count", msg.ConnectedPeersCount),
232+
zap.String("storage", msg.Storage),
233+
}
234+
if msg.MinMiningTxFee != nil {
235+
fields = append(fields, zap.Float64("min_mining_tx_fee", *msg.MinMiningTxFee))
236+
}
237+
ce.Write(fields...)
238+
}
239+
208240
raw := pickDatahubURL(msg)
209241
if raw == "" {
210242
metrics.P2PEndpointDiscoveryTotal.WithLabelValues("no_url").Inc()

0 commit comments

Comments
 (0)