Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
icorderi committed Dec 7, 2022
1 parent ae6b35b commit 70b8113
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 2 additions & 3 deletions ledger/accountdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (a *compactResourcesDeltas) resourcesLoadOld(tx *sql.Tx, knownAddresses map
if delta.oldResource.Addrid != 0 {
addrid = delta.oldResource.Addrid
} else if addrid, ok = knownAddresses[addr]; !ok {
addrid, err = arw.LookupAccountRowId(addr)
addrid, err = arw.LookupAccountRowID(addr)
if err != nil {
if err != sql.ErrNoRows {
err = fmt.Errorf("base account cannot be read while processing resource for addr=%s, aidx=%d: %w", addr.String(), aidx, err)
Expand All @@ -330,7 +330,7 @@ func (a *compactResourcesDeltas) resourcesLoadOld(tx *sql.Tx, knownAddresses map
continue
}
}
resDataBuf, err = arw.LookupResourceDataByAddrId(addrid, aidx)
resDataBuf, err = arw.LookupResourceDataByAddrID(addrid, aidx)
switch err {
case nil:
if len(resDataBuf) > 0 {
Expand Down Expand Up @@ -624,7 +624,6 @@ func (a *compactOnlineAccountDeltas) accountsLoadOld(tx *sql.Tx) (err error) {
case sql.ErrNoRows:
// we don't have that account, just return an empty record.
a.updateOld(idx, store.PersistedOnlineAccountData{Addr: addr})
err = nil
default:
// unexpected error - let the caller know that we couldn't complete the operation.
return err
Expand Down
17 changes: 10 additions & 7 deletions ledger/store/accountsV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewAccountsSQLReaderWriter(e db.Executable) *accountsV2ReaderWriter {
}
}

func (r *accountsV2Reader) get_or_prepare(key string, queryString string) (stmt *sql.Stmt, err error) {
func (r *accountsV2Reader) getOrPrepare(key string, queryString string) (stmt *sql.Stmt, err error) {
// fetch statement
if stmt, ok := r.preparedStatements[key]; ok {
return stmt, nil
Expand Down Expand Up @@ -288,7 +288,7 @@ func (r *accountsV2Reader) LookupAccountAddressFromAddressID(ctx context.Context

func (r *accountsV2Reader) LookupAccountDataByAddress(addr basics.Address) (rowid int64, data []byte, err error) {
// optimize this query for repeated usage
selectStmt, err := r.get_or_prepare("LookupAccountDataByAddress", "SELECT rowid, data FROM accountbase WHERE address=?")
selectStmt, err := r.getOrPrepare("LookupAccountDataByAddress", "SELECT rowid, data FROM accountbase WHERE address=?")
if err != nil {
return
}
Expand All @@ -300,9 +300,10 @@ func (r *accountsV2Reader) LookupAccountDataByAddress(addr basics.Address) (rowi
return rowid, data, err
}

// LookupOnlineAccountDataByAddress looks up online account data by address.
func (r *accountsV2Reader) LookupOnlineAccountDataByAddress(addr basics.Address) (rowid int64, data []byte, err error) {
// optimize this query for repeated usage
selectStmt, err := r.get_or_prepare(
selectStmt, err := r.getOrPrepare(
"LookupOnlineAccountDataByAddress",
"SELECT rowid, data FROM onlineaccounts WHERE address=? ORDER BY updround DESC LIMIT 1",
)
Expand All @@ -317,9 +318,10 @@ func (r *accountsV2Reader) LookupOnlineAccountDataByAddress(addr basics.Address)
return rowid, data, err
}

func (r *accountsV2Reader) LookupAccountRowId(addr basics.Address) (rowid int64, err error) {
// LookupAccountRowID looks up the rowid of an account based on its address.
func (r *accountsV2Reader) LookupAccountRowID(addr basics.Address) (rowid int64, err error) {
// optimize this query for repeated usage
addrRowidStmt, err := r.get_or_prepare("LookupAccountRowId", "SELECT rowid FROM accountbase WHERE address=?")
addrRowidStmt, err := r.getOrPrepare("LookupAccountRowId", "SELECT rowid FROM accountbase WHERE address=?")
if err != nil {
return
}
Expand All @@ -331,9 +333,10 @@ func (r *accountsV2Reader) LookupAccountRowId(addr basics.Address) (rowid int64,
return rowid, err
}

func (r *accountsV2Reader) LookupResourceDataByAddrId(addrid int64, aidx basics.CreatableIndex) (data []byte, err error) {
// LookupResourceDataByAddrID looks up the resource data by account rowid + resource aidx.
func (r *accountsV2Reader) LookupResourceDataByAddrID(addrid int64, aidx basics.CreatableIndex) (data []byte, err error) {
// optimize this query for repeated usage
selectStmt, err := r.get_or_prepare("LookupResourceDataByAddrId", "SELECT data FROM resources WHERE addrid = ? AND aidx = ?")
selectStmt, err := r.getOrPrepare("LookupResourceDataByAddrId", "SELECT data FROM resources WHERE addrid = ? AND aidx = ?")
if err != nil {
return
}
Expand Down

0 comments on commit 70b8113

Please sign in to comment.