Skip to content

Commit

Permalink
chore(mempool): add timeout of checktx for p2p messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 15, 2024
1 parent 2109237 commit 80f3c9c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/mempool/p2p_msg_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import (
"github.com/dashpay/tenderdash/types"
)

const (
// max time to wait for a response from CheckTx
p2pCheckTxTimeout = 5 * time.Second
)

type (
mempoolP2PMessageHandler struct {
logger log.Logger
Expand Down Expand Up @@ -58,6 +63,9 @@ func (h *mempoolP2PMessageHandler) Handle(ctx context.Context, _ *client.Client,
known := 0
failed := 0
for _, tx := range protoTxs {
// TODO: Move to abciclient, define configuration settings
ctx, cancel := context.WithTimeout(ctx, p2pCheckTxTimeout)
defer cancel()
if err := h.checker.CheckTx(ctx, tx, nil, txInfo); err != nil {
if errors.Is(err, types.ErrTxInCache) {
// if the tx is in the cache,
Expand Down

0 comments on commit 80f3c9c

Please sign in to comment.