Skip to content

Commit

Permalink
Chore: more deadcode (algorand#5495)
Browse files Browse the repository at this point in the history
  • Loading branch information
jannotti authored Jun 23, 2023
1 parent f514d82 commit c547097
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 45 deletions.
2 changes: 0 additions & 2 deletions ledger/store/trackerdb/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ type AccountsWriterExt interface {
// AccountsReader is the "optimized" read interface for:
// - accounts, resources, app kvs, creatables
type AccountsReader interface {
ListCreatables(maxIdx basics.CreatableIndex, maxResults uint64, ctype basics.CreatableType) (results []basics.CreatableLocator, dbRound basics.Round, err error)

LookupAccount(addr basics.Address) (data PersistedAccountData, err error)

LookupResources(addr basics.Address, aidx basics.CreatableIndex, ctype basics.CreatableType) (data PersistedResourcesData, err error)
Expand Down
40 changes: 0 additions & 40 deletions ledger/store/trackerdb/sqlitedriver/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
// accountsDbQueries is used to cache a prepared SQL statement to look up
// the state of a single account.
type accountsDbQueries struct {
listCreatablesStmt *sql.Stmt
lookupAccountStmt *sql.Stmt
lookupResourcesStmt *sql.Stmt
lookupAllResourcesStmt *sql.Stmt
Expand Down Expand Up @@ -70,11 +69,6 @@ func AccountsInitDbQueries(q db.Queryable) (*accountsDbQueries, error) {
var err error
qs := &accountsDbQueries{}

qs.listCreatablesStmt, err = q.Prepare("SELECT acctrounds.rnd, assetcreators.asset, assetcreators.creator FROM acctrounds LEFT JOIN assetcreators ON assetcreators.asset <= ? AND assetcreators.ctype = ? WHERE acctrounds.id='acctbase' ORDER BY assetcreators.asset desc LIMIT ?")
if err != nil {
return nil, err
}

qs.lookupAccountStmt, err = q.Prepare("SELECT accountbase.rowid, acctrounds.rnd, accountbase.data FROM acctrounds LEFT JOIN accountbase ON address=? WHERE id='acctbase'")
if err != nil {
return nil, err
Expand Down Expand Up @@ -208,39 +202,6 @@ func MakeAccountsSQLWriter(e db.Executable, hasAccounts, hasResources, hasKvPair
return
}

// ListCreatables returns an array of CreatableLocator which have CreatableIndex smaller or equal to maxIdx and are of the provided CreatableType.
func (qs *accountsDbQueries) ListCreatables(maxIdx basics.CreatableIndex, maxResults uint64, ctype basics.CreatableType) (results []basics.CreatableLocator, dbRound basics.Round, err error) {
err = db.Retry(func() error {
// Query for assets in range
rows, err := qs.listCreatablesStmt.Query(maxIdx, ctype, maxResults)
if err != nil {
return err
}
defer rows.Close()

// For each row, copy into a new CreatableLocator and append to results
var buf []byte
var cl basics.CreatableLocator
var creatableIndex sql.NullInt64
for rows.Next() {
err = rows.Scan(&dbRound, &creatableIndex, &buf)
if err != nil {
return err
}
if !creatableIndex.Valid {
// we received an entry without any index. This would happen only on the first entry when there are no creatables of the requested type.
break
}
cl.Index = basics.CreatableIndex(creatableIndex.Int64)
copy(cl.Creator[:], buf)
cl.Type = ctype
results = append(results, cl)
}
return nil
})
return
}

// sql.go has the following contradictory comments:

// Reference types such as []byte are only valid until the next call to Scan
Expand Down Expand Up @@ -571,7 +532,6 @@ func (qs *onlineAccountsDbQueries) LookupOnlineHistory(addr basics.Address) (res

func (qs *accountsDbQueries) Close() {
preparedQueries := []**sql.Stmt{
&qs.listCreatablesStmt,
&qs.lookupAccountStmt,
&qs.lookupResourcesStmt,
&qs.lookupAllResourcesStmt,
Expand Down
6 changes: 3 additions & 3 deletions ledger/store/trackerdb/sqlitedriver/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func TestAccountsDbQueriesCreateClose(t *testing.T) {
require.NoError(t, err)
qs, err := AccountsInitDbQueries(dbs.Rdb.Handle)
require.NoError(t, err)
require.NotNil(t, qs.listCreatablesStmt)
require.NotNil(t, qs.lookupAccountStmt)
qs.Close()
require.Nil(t, qs.listCreatablesStmt)
require.Nil(t, qs.lookupAccountStmt)
qs.Close()
require.Nil(t, qs.listCreatablesStmt)
require.Nil(t, qs.lookupAccountStmt)
}

0 comments on commit c547097

Please sign in to comment.