Skip to content

Commit 65ebe38

Browse files
committed
Bugfixes (pointer to range variable)
1 parent 8df941a commit 65ebe38

3 files changed

Lines changed: 4 additions & 14 deletions

File tree

indexer/xchain/in_updater.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func (iu *xChainInputUpdater) updateFromDB(
4747
return nil, err
4848
}
4949
baseOuts := shared.NewOutputMap()
50-
for _, out := range outs {
51-
baseOuts.Add(shared.NewIdIndexKey(out.TxID, out.Index()), &out.TxOutput)
50+
for i, out := range outs {
51+
baseOuts.Add(shared.NewIdIndexKey(out.TxID, out.Index()), &outs[i].TxOutput)
5252
}
5353
return inputs.UpdateWithOutputs(baseOuts), nil
5454
}

services/api/pchain.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ func newApiPChainTxListItem(tx *database.PChainTxData) ApiPChainTxListItem {
9898

9999
func NewApiPChainTxList(txs []database.PChainTxData) []ApiPChainTxListItem {
100100
result := make([]ApiPChainTxListItem, len(txs))
101-
for i, tx := range txs {
102-
result[i] = newApiPChainTxListItem(&tx)
101+
for i := range txs {
102+
result[i] = newApiPChainTxListItem(&txs[i])
103103
}
104-
105104
return result
106105
}

utils/structures.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ func ArrayToMap[T, K comparable](ts []T, kf func(T) K) map[K]T {
1919
return result
2020
}
2121

22-
// Create a map from array with kf providing keys, values are pointers to array elements
23-
func ArrayToPtrMap[T, K comparable](ts []T, kf func(T) K) map[K]*T {
24-
result := make(map[K]*T)
25-
for _, t := range ts {
26-
result[kf(t)] = &t
27-
}
28-
return result
29-
}
30-
3122
func Keys[K comparable, V any](m map[K]V) []K {
3223
keys := make([]K, 0, len(m))
3324
for k := range m {

0 commit comments

Comments
 (0)