Skip to content

Commit

Permalink
Bugfixes (pointer to range variable)
Browse files Browse the repository at this point in the history
  • Loading branch information
mboben committed Feb 14, 2024
1 parent 8df941a commit 65ebe38
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
4 changes: 2 additions & 2 deletions indexer/xchain/in_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (iu *xChainInputUpdater) updateFromDB(
return nil, err
}
baseOuts := shared.NewOutputMap()
for _, out := range outs {
baseOuts.Add(shared.NewIdIndexKey(out.TxID, out.Index()), &out.TxOutput)
for i, out := range outs {
baseOuts.Add(shared.NewIdIndexKey(out.TxID, out.Index()), &outs[i].TxOutput)
}
return inputs.UpdateWithOutputs(baseOuts), nil
}
Expand Down
5 changes: 2 additions & 3 deletions services/api/pchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ func newApiPChainTxListItem(tx *database.PChainTxData) ApiPChainTxListItem {

func NewApiPChainTxList(txs []database.PChainTxData) []ApiPChainTxListItem {
result := make([]ApiPChainTxListItem, len(txs))
for i, tx := range txs {
result[i] = newApiPChainTxListItem(&tx)
for i := range txs {
result[i] = newApiPChainTxListItem(&txs[i])
}

return result
}
9 changes: 0 additions & 9 deletions utils/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ func ArrayToMap[T, K comparable](ts []T, kf func(T) K) map[K]T {
return result
}

// Create a map from array with kf providing keys, values are pointers to array elements
func ArrayToPtrMap[T, K comparable](ts []T, kf func(T) K) map[K]*T {
result := make(map[K]*T)
for _, t := range ts {
result[kf(t)] = &t
}
return result
}

func Keys[K comparable, V any](m map[K]V) []K {
keys := make([]K, 0, len(m))
for k := range m {
Expand Down

0 comments on commit 65ebe38

Please sign in to comment.