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 0a38215f08..c721f9e4ba 100644 --- a/services/horizon/internal/ingest/processors/liquidity_pools_transaction_processor.go +++ b/services/horizon/internal/ingest/processors/liquidity_pools_transaction_processor.go @@ -2,10 +2,10 @@ package processors import ( "context" + "sort" "github.com/stellar/go/ingest" "github.com/stellar/go/services/horizon/internal/db2/history" - "github.com/stellar/go/support/collections/set" "github.com/stellar/go/support/db" "github.com/stellar/go/support/errors" "github.com/stellar/go/toid" @@ -73,16 +73,21 @@ func liquidityPoolsForTransaction(transaction ingest.LedgerTransaction) ([]strin } func dedupeStrings(in []string) []string { - set := set.Set[string]{} - for _, id := range in { - set.Add(id) + if len(in) <= 1 { + return in } - - out := make([]string, 0, len(in)) - for id := range set { - out = append(out, id) + sort.Strings(in) + insert := 1 + for cur := 1; cur < len(in); cur++ { + if in[cur] == in[cur-1] { + continue + } + if insert != cur { + in[insert] = in[cur] + } + insert++ } - return out + return in[:insert] } func liquidityPoolsForChanges( diff --git a/services/horizon/internal/ingest/processors/operations_processor.go b/services/horizon/internal/ingest/processors/operations_processor.go index b9a23229d5..8ad023145c 100644 --- a/services/horizon/internal/ingest/processors/operations_processor.go +++ b/services/horizon/internal/ingest/processors/operations_processor.go @@ -5,6 +5,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "sort" "github.com/guregu/null" @@ -1034,16 +1035,25 @@ func (operation *transactionOperationWrapper) Participants() ([]xdr.AccountId, e } // dedupeParticipants remove any duplicate ids from `in` -func dedupeParticipants(in []xdr.AccountId) (out []xdr.AccountId) { - set := map[string]xdr.AccountId{} - for _, id := range in { - set[id.Address()] = id +func dedupeParticipants(in []xdr.AccountId) []xdr.AccountId { + if len(in) <= 1 { + return in } - - for _, id := range set { - out = append(out, id) + sort.Slice(in, func(i, j int) bool { + return in[i].Address() < in[j].Address() + }) + insert := 1 + for cur := 1; cur < len(in); cur++ { + if in[cur].Equals(in[cur-1]) { + continue + } + if insert != cur { + in[insert] = in[cur] + } + insert++ } - return + return in[:insert] + } // OperationsParticipants returns a map with all participants per operation