From 340ef7fd059d31274b9d1cd47514579a6db9cb65 Mon Sep 17 00:00:00 2001 From: pr0n1x Date: Tue, 28 Nov 2023 13:41:08 +0700 Subject: [PATCH] Fixed panic in SubscribeOnTransactions method --- ton/transactions.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ton/transactions.go b/ton/transactions.go index f6aaabc0..0fe4d402 100644 --- a/ton/transactions.go +++ b/ton/transactions.go @@ -250,18 +250,18 @@ func (c *APIClient) SubscribeOnTransactions(workerCtx context.Context, addr *add transactions = append(transactions, res...) waitList = 0 * time.Second } - lastProcessedLT = transactions[0].LT // mark last transaction as known to not trigger twice + if len(transactions) > 0 { + lastProcessedLT = transactions[0].LT // mark last transaction as known to not trigger twice - // reverse slice to send in correct time order (from old to new) - for i, j := 0, len(transactions)-1; i < j; i, j = i+1, j-1 { - transactions[i], transactions[j] = transactions[j], transactions[i] - } + // reverse slice to send in correct time order (from old to new) + for i, j := 0, len(transactions)-1; i < j; i, j = i+1, j-1 { + transactions[i], transactions[j] = transactions[j], transactions[i] + } - for _, tx := range transactions { - channel <- tx - } + for _, tx := range transactions { + channel <- tx + } - if len(transactions) > 0 { wait = 0 * time.Second } }