Skip to content

Commit

Permalink
Merge pull request spacemeshos#1 from zhiqiangxu/ky-dev
Browse files Browse the repository at this point in the history
add some log
  • Loading branch information
remakeZK authored Mar 13, 2024
2 parents 794c4ef + 5bb30a4 commit 509d343
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fetch/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,24 @@ func (h *handler) handleHashReq(ctx context.Context, data []byte) ([]byte, error
totalHashReqs.WithLabelValues(string(r.Hint)).Add(1)
res, err := h.bs.Get(r.Hint, r.Hash.Bytes())
if err != nil {
h.logger.WithContext(ctx).With().Debug("serve: remote peer requested nonexistent hash",
h.logger.WithContext(ctx).With().Warning("serve: remote peer requested nonexistent hash",
log.String("hash", r.Hash.ShortString()),
log.Stringer("batch", requestBatch.ID),
log.String("hint", string(r.Hint)),
log.Err(err))
hashMissing.WithLabelValues(string(r.Hint)).Add(1)
continue
} else if res == nil {
h.logger.WithContext(ctx).With().Debug("serve: remote peer requested golden",
h.logger.WithContext(ctx).With().Warning("serve: remote peer requested golden",
log.String("hash", r.Hash.ShortString()),
log.Stringer("batch", requestBatch.ID),
log.Int("dataSize", len(res)))
hashEmptyData.WithLabelValues(string(r.Hint)).Add(1)
continue
} else {
h.logger.WithContext(ctx).With().Debug("serve: responded to hash request",
h.logger.WithContext(ctx).With().Warning("serve: responded to hash request",
log.String("hash", r.Hash.ShortString()),
log.Stringer("batch", requestBatch.ID),
log.Int("dataSize", len(res)))
}
// add response to batch
Expand All @@ -207,7 +210,7 @@ func (h *handler) handleHashReq(ctx context.Context, data []byte) ([]byte, error
log.Err(err),
log.String("batch_hash", resBatch.ID.ShortString()))
}
h.logger.WithContext(ctx).With().Debug("serve: returning response for batch",
h.logger.WithContext(ctx).With().Warning("serve: returning response for batch",
log.String("batch_hash", resBatch.ID.ShortString()),
log.Int("count_responses", len(resBatch.Responses)),
log.Int("data_size", len(bts)))
Expand Down

0 comments on commit 509d343

Please sign in to comment.