Skip to content

Commit

Permalink
updated removeDuplicates func
Browse files Browse the repository at this point in the history
  • Loading branch information
MonikaCat committed Jan 22, 2024
1 parent 548d11b commit c08d1a3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions database/legacy/msgexec/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

0 comments on commit c08d1a3

Please sign in to comment.