Skip to content

Commit

Permalink
Merge pull request #531 from tonkeeper/speedup-sending-msg
Browse files Browse the repository at this point in the history
Speed up msg sending
  • Loading branch information
mr-tron authored Nov 11, 2024
2 parents da30495 + d084374 commit 63d4d18
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/blockchain/msg_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type ExtInMsgCopy struct {
Details any
// Accounts is set when the message is emulated.
Accounts map[tongo.AccountID]struct{}

SendFailed bool // default is false, so we are good with backward compatibility.
}

var liteserverMessageSendMc = promauto.NewCounterVec(prometheus.CounterOpts{
Expand Down Expand Up @@ -144,14 +146,17 @@ func (ms *MsgSender) SendMessage(ctx context.Context, msgCopy ExtInMsgCopy) erro
if err := liteapi.VerifySendMessagePayload(msgCopy.Payload); err != nil {
return err
}
err := ms.send(ctx, msgCopy.Payload)
msgCopy.SendFailed = err != nil

for name, ch := range ms.receivers {
select {
case ch <- msgCopy:
default:
ms.logger.Warn("receiver is too slow", zap.String("name", name))
}
}
return ms.send(ctx, msgCopy.Payload)
return nil
}

func (ms *MsgSender) send(ctx context.Context, payload []byte) error {
Expand Down

0 comments on commit 63d4d18

Please sign in to comment.