From c08d1a329cc7b1af116b456b823ff4e27286c161 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Mon, 22 Jan 2024 20:58:41 +0700 Subject: [PATCH] updated removeDuplicates func --- database/legacy/msgexec/migrate.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/database/legacy/msgexec/migrate.go b/database/legacy/msgexec/migrate.go index ef66a3c1..5c5a78fb 100644 --- a/database/legacy/msgexec/migrate.go +++ b/database/legacy/msgexec/migrate.go @@ -10,7 +10,6 @@ import ( "github.com/rs/zerolog/log" dbtypes "github.com/forbole/juno/v5/database/migrate/utils" - msgmodule "github.com/forbole/juno/v5/modules/messages" "github.com/forbole/juno/v5/types" ) @@ -54,7 +53,7 @@ func (db *Migrator) Migrate() error { } } } - involvedAddresses := msgmodule.RemoveDuplicates(addresses) + involvedAddresses := db.removeDuplicates(addresses) fmt.Printf("\n ADDRESSES BEFORE %s", msgType.InvolvedAccountsAddresses) fmt.Printf("\n ADDRESSES AFTER %s \n", involvedAddresses) @@ -121,3 +120,16 @@ ON CONFLICT (transaction_hash, index, partition_id) DO UPDATE return err } + +// function to remove duplicate values +func (db *Migrator) removeDuplicates(s []string) []string { + bucket := make(map[string]bool) + var result []string + for _, str := range s { + if _, ok := bucket[str]; !ok { + bucket[str] = true + result = append(result, str) + } + } + return result +}