From 8d72fc4a94637c6b40748d543e580041fc7f85de Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Wed, 8 Mar 2023 21:37:02 -0600 Subject: [PATCH] fix: copy loop var to avoid overwriting value --- ledger/allegra.go | 4 +++- ledger/alonzo.go | 4 +++- ledger/babbage.go | 4 +++- ledger/mary.go | 4 +++- ledger/shelley.go | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ledger/allegra.go b/ledger/allegra.go index 1843dc0a..730fe8d3 100644 --- a/ledger/allegra.go +++ b/ledger/allegra.go @@ -48,7 +48,9 @@ func (b *AllegraBlock) Era() Era { func (b *AllegraBlock) Transactions() []TransactionBody { ret := []TransactionBody{} for _, v := range b.TransactionBodies { - ret = append(ret, &v) + // Create temp var since we take the address and the loop var gets reused + tmpVal := v + ret = append(ret, &tmpVal) } return ret } diff --git a/ledger/alonzo.go b/ledger/alonzo.go index 916435b7..6f073edf 100644 --- a/ledger/alonzo.go +++ b/ledger/alonzo.go @@ -49,7 +49,9 @@ func (b *AlonzoBlock) Era() Era { func (b *AlonzoBlock) Transactions() []TransactionBody { ret := []TransactionBody{} for _, v := range b.TransactionBodies { - ret = append(ret, &v) + // Create temp var since we take the address and the loop var gets reused + tmpVal := v + ret = append(ret, &tmpVal) } return ret } diff --git a/ledger/babbage.go b/ledger/babbage.go index 23b1ee42..5933517c 100644 --- a/ledger/babbage.go +++ b/ledger/babbage.go @@ -49,7 +49,9 @@ func (b *BabbageBlock) Era() Era { func (b *BabbageBlock) Transactions() []TransactionBody { ret := []TransactionBody{} for _, v := range b.TransactionBodies { - ret = append(ret, &v) + // Create temp var since we take the address and the loop var gets reused + tmpVal := v + ret = append(ret, &tmpVal) } return ret } diff --git a/ledger/mary.go b/ledger/mary.go index ec498392..8c5e9525 100644 --- a/ledger/mary.go +++ b/ledger/mary.go @@ -48,7 +48,9 @@ func (b *MaryBlock) Era() Era { func (b *MaryBlock) Transactions() []TransactionBody { ret := []TransactionBody{} for _, v := range b.TransactionBodies { - ret = append(ret, &v) + // Create temp var since we take the address and the loop var gets reused + tmpVal := v + ret = append(ret, &tmpVal) } return ret } diff --git a/ledger/shelley.go b/ledger/shelley.go index 248f0aa5..933b49c6 100644 --- a/ledger/shelley.go +++ b/ledger/shelley.go @@ -48,7 +48,9 @@ func (b *ShelleyBlock) Era() Era { func (b *ShelleyBlock) Transactions() []TransactionBody { ret := []TransactionBody{} for _, v := range b.TransactionBodies { - ret = append(ret, &v) + // Create temp var since we take the address and the loop var gets reused + tmpVal := v + ret = append(ret, &tmpVal) } return ret }