[P2P] Improve debug logging
add send block notice log
@@ -126,12 +126,13 @@ func (pr *pbBlkNoticeOrder) SendTo(pi p2pcommon.RemotePeer) error {
}
if skipNotice || passedTime < MinNewBlkNotiInterval {
p.skipCnt++
+ if p.skipCnt&0x03ff == 0 {
+ p.logger.Debug().Str(p2putil.LogPeerName, p.Name()).Str(p2putil.LogProtoID, pr.GetProtocolID().String()).Int32("skip_cnt", p.skipCnt).Msg("Skipped NewBlockNotice ")
+
+ }
return nil
}
- if p.skipCnt > 100 {
- p.logger.Debug().Str(p2putil.LogPeerName, p.Name()).Str(p2putil.LogProtoID, pr.GetProtocolID().String()).Int32("skip_cnt", p.skipCnt).Str(p2putil.LogMsgID, pr.GetMsgID().String()).Str(p2putil.LogOrgReqID, pr.message.OriginalID().String()).Msg("Send NewBlockNotice after long skip")
- }
if ok, _ := p.blkHashCache.ContainsOrAdd(blkhash, cachePlaceHolder); ok {
// the remote peer already know this block hash. skip it
// too many not-insteresting log,
@@ -144,8 +145,11 @@ func (pr *pbBlkNoticeOrder) SendTo(pi p2pcommon.RemotePeer) error {
p.logger.Warn().Str(p2putil.LogPeerName, p.Name()).Str(p2putil.LogProtoID, pr.GetProtocolID().String()).Str(p2putil.LogMsgID, pr.GetMsgID().String()).Err(err).Msg("fail to SendTo")
return err
}
- p.skipCnt = 0
p.lastBlkNoticeTime = time.Now()
+ if p.skipCnt > 100 {
+ p.logger.Debug().Str(p2putil.LogPeerName, p.Name()).Str(p2putil.LogProtoID, pr.GetProtocolID().String()).Int32("skip_cnt", p.skipCnt).Msg("Send NewBlockNotice after long skip")
+ }
+ p.skipCnt = 0
return nil
}
