From 45aee86a48443320f3f7f5bec6222331edff0db6 Mon Sep 17 00:00:00 2001 From: tamirms Date: Wed, 3 Jan 2024 13:06:17 +0100 Subject: [PATCH] fix empty array bug --- .../ingest/processors/liquidity_pools_transaction_processor.go | 3 +++ .../horizon/internal/ingest/processors/operations_processor.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/services/horizon/internal/ingest/processors/liquidity_pools_transaction_processor.go b/services/horizon/internal/ingest/processors/liquidity_pools_transaction_processor.go index a4e5886e73..c721f9e4ba 100644 --- a/services/horizon/internal/ingest/processors/liquidity_pools_transaction_processor.go +++ b/services/horizon/internal/ingest/processors/liquidity_pools_transaction_processor.go @@ -73,6 +73,9 @@ func liquidityPoolsForTransaction(transaction ingest.LedgerTransaction) ([]strin } func dedupeStrings(in []string) []string { + if len(in) <= 1 { + return in + } sort.Strings(in) insert := 1 for cur := 1; cur < len(in); cur++ { diff --git a/services/horizon/internal/ingest/processors/operations_processor.go b/services/horizon/internal/ingest/processors/operations_processor.go index b74f682a71..8ad023145c 100644 --- a/services/horizon/internal/ingest/processors/operations_processor.go +++ b/services/horizon/internal/ingest/processors/operations_processor.go @@ -1036,6 +1036,9 @@ func (operation *transactionOperationWrapper) Participants() ([]xdr.AccountId, e // dedupeParticipants remove any duplicate ids from `in` func dedupeParticipants(in []xdr.AccountId) []xdr.AccountId { + if len(in) <= 1 { + return in + } sort.Slice(in, func(i, j int) bool { return in[i].Address() < in[j].Address() })