Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return TotalAppSchema and TotalExtraAppPages from AccountData #784

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions idb/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ func (db *IndexerDb) yieldAccountsThread(req *getAccountsRequest) {
account.SigType = keytype
}

if accountDataJSONStr != nil {
{
var ad basics.AccountData
ad, err = encoding.DecodeTrimmedAccountData(accountDataJSONStr)
if err != nil {
Expand Down Expand Up @@ -1009,6 +1009,19 @@ func (db *IndexerDb) yieldAccountsThread(req *getAccountsRequest) {
copy(spendingkey[:], ad.AuthAddr[:])
account.AuthAddr = stringPtr(spendingkey.String())
}

{
totalSchema := models.ApplicationStateSchema{
NumByteSlice: ad.TotalAppSchema.NumByteSlice,
NumUint: ad.TotalAppSchema.NumUint,
}
if totalSchema != (models.ApplicationStateSchema{}) {
account.AppsTotalSchema = &totalSchema
}
}
if ad.TotalExtraAppPages != 0 {
account.AppsTotalExtraPages = uint64Ptr(uint64(ad.TotalExtraAppPages))
}
}

if account.Status == "NotParticipating" {
Expand Down Expand Up @@ -1197,8 +1210,6 @@ func (db *IndexerDb) yieldAccountsThread(req *getAccountsRequest) {
*account.CreatedAssets = cal
}

var totalSchema models.ApplicationStateSchema

if len(appParamIndexes) > 0 {
// apps owned by this account
var appIds []uint64
Expand Down Expand Up @@ -1242,7 +1253,6 @@ func (db *IndexerDb) yieldAccountsThread(req *getAccountsRequest) {
break
}

var totalExtraPages uint64
aout := make([]models.Application, len(appIds))
outpos := 0
for i, appid := range appIds {
Expand Down Expand Up @@ -1271,22 +1281,13 @@ func (db *IndexerDb) yieldAccountsThread(req *getAccountsRequest) {
aout[outpos].Params.ExtraProgramPages = &epp
}
}
if aout[outpos].Deleted == nil || !*aout[outpos].Deleted {
totalSchema.NumByteSlice += apps[i].GlobalStateSchema.NumByteSlice
totalSchema.NumUint += apps[i].GlobalStateSchema.NumUint
totalExtraPages += uint64(apps[i].ExtraProgramPages)
}

outpos++
}
if outpos != len(aout) {
aout = aout[:outpos]
}
account.CreatedApps = &aout

if totalExtraPages != 0 {
account.AppsTotalExtraPages = &totalExtraPages
}
}

if len(localStateAppIds) > 0 {
Expand Down Expand Up @@ -1341,18 +1342,10 @@ func (db *IndexerDb) yieldAccountsThread(req *getAccountsRequest) {
NumUint: ls[i].Schema.NumUint,
}
aout[i].KeyValue = tealKeyValueToModel(ls[i].KeyValue)
if aout[i].Deleted == nil || !*aout[i].Deleted {
totalSchema.NumByteSlice += ls[i].Schema.NumByteSlice
totalSchema.NumUint += ls[i].Schema.NumUint
}
}
account.AppsLocalState = &aout
}

if totalSchema != (models.ApplicationStateSchema{}) {
account.AppsTotalSchema = &totalSchema
}

select {
case req.out <- idb.AccountRow{Account: account}:
count++
Expand Down