summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTsachi Herman <tsachi.herman@algorand.com>2022-02-23 13:48:55 -0500
committerGitHub <noreply@github.com>2022-02-23 13:48:55 -0500
commitf41b62480aad8e6041a0ea89dccd9c445b2a7adb (patch)
tree4e74a924cf175378fdea1d4792f736bb3c1fd032
parentc661566d80d3c0973b774928dc4b557a983eaea8 (diff)
ledger refactoring: make changes per CR (#3677)
## Summary Pass the `ledgercore.AccountData` to the `accountDataToOnline` as a pointer rather then copy of the actual data. ## Test Plan Update tests
-rw-r--r--ledger/accountdb.go4
-rw-r--r--ledger/accountdb_test.go2
-rw-r--r--ledger/acctupdates.go2
3 files changed, 4 insertions, 4 deletions
diff --git a/ledger/accountdb.go b/ledger/accountdb.go
index 96983c1ef..66007bfdd 100644
--- a/ledger/accountdb.go
+++ b/ledger/accountdb.go
@@ -1802,7 +1802,7 @@ func removeEmptyAccountData(tx *sql.Tx, queryAddresses bool) (num int64, address
// the full AccountData because we need to store a large number of these
// in memory (say, 1M), and storing that many AccountData could easily
// cause us to run out of memory.
-func accountDataToOnline(address basics.Address, ad ledgercore.AccountData, proto config.ConsensusParams) *ledgercore.OnlineAccount {
+func accountDataToOnline(address basics.Address, ad *ledgercore.AccountData, proto config.ConsensusParams) *ledgercore.OnlineAccount {
return &ledgercore.OnlineAccount{
Address: address,
MicroAlgos: ad.MicroAlgos,
@@ -2256,7 +2256,7 @@ func accountsOnlineTop(tx *sql.Tx, offset, n uint64, proto config.ConsensusParam
copy(addr[:], addrbuf)
ad := data.GetLedgerCoreAccountData()
- res[addr] = accountDataToOnline(addr, ad, proto)
+ res[addr] = accountDataToOnline(addr, &ad, proto)
}
return res, rows.Err()
diff --git a/ledger/accountdb_test.go b/ledger/accountdb_test.go
index d71509c71..b771d1532 100644
--- a/ledger/accountdb_test.go
+++ b/ledger/accountdb_test.go
@@ -115,7 +115,7 @@ func checkAccounts(t *testing.T, tx *sql.Tx, rnd basics.Round, accts map[basics.
for addr, data := range accts {
if data.Status == basics.Online {
ad := ledgercore.ToAccountData(data)
- onlineAccounts[addr] = accountDataToOnline(addr, ad, proto)
+ onlineAccounts[addr] = accountDataToOnline(addr, &ad, proto)
}
}
diff --git a/ledger/acctupdates.go b/ledger/acctupdates.go
index bc8c2d787..89ed04392 100644
--- a/ledger/acctupdates.go
+++ b/ledger/acctupdates.go
@@ -434,7 +434,7 @@ func (au *accountUpdates) onlineTop(rnd basics.Round, voteRnd basics.Round, n ui
continue
}
- modifiedAccounts[addr] = accountDataToOnline(addr, d, proto)
+ modifiedAccounts[addr] = accountDataToOnline(addr, &d, proto)
}
}