From d08437483d147e63c4580a1d393a173316ce928c Mon Sep 17 00:00:00 2001 From: "aleksej.paschenko" Date: Mon, 11 Nov 2024 10:27:12 +0300 Subject: [PATCH] Speed up msg sending --- pkg/blockchain/msg_sender.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/blockchain/msg_sender.go b/pkg/blockchain/msg_sender.go index f8e99483..ffabd89b 100644 --- a/pkg/blockchain/msg_sender.go +++ b/pkg/blockchain/msg_sender.go @@ -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{ @@ -144,6 +146,9 @@ 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: @@ -151,7 +156,7 @@ func (ms *MsgSender) SendMessage(ctx context.Context, msgCopy ExtInMsgCopy) erro 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 {