Skip to content

Commit

Permalink
chore(mempool): log when txs are processed
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 15, 2024
1 parent b0224ef commit 2109237
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/mempool/p2p_msg_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

"github.com/dashpay/tenderdash/internal/p2p"
"github.com/dashpay/tenderdash/internal/p2p/client"
Expand Down Expand Up @@ -52,6 +53,10 @@ func (h *mempoolP2PMessageHandler) Handle(ctx context.Context, _ *client.Client,
SenderID: h.ids.GetForPeer(envelope.From),
SenderNodeID: envelope.From,
}
// some stats for logging
start := time.Now()
known := 0
failed := 0
for _, tx := range protoTxs {
if err := h.checker.CheckTx(ctx, tx, nil, txInfo); err != nil {
if errors.Is(err, types.ErrTxInCache) {
Expand All @@ -61,6 +66,7 @@ func (h *mempoolP2PMessageHandler) Handle(ctx context.Context, _ *client.Client,
// got. Gossip should be
// smarter, but it's not a
// problem.
known++
continue
}
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
Expand All @@ -71,10 +77,16 @@ func (h *mempoolP2PMessageHandler) Handle(ctx context.Context, _ *client.Client,
// message if we are shutting down.
return err
}
failed++
logger.Error("checktx failed for tx",
"tx", fmt.Sprintf("%X", types.Tx(tx).Hash()),
"error", err)
}
}
logger.Debug("processed txs from peer", "took", time.Since(start).String(),
"num_txs", len(protoTxs),
"already_known", known,
"failed", failed,
)
return nil
}

0 comments on commit 2109237

Please sign in to comment.