Skip to content

Commit

Permalink
cloudspanner: Move GetActiveLogIDs to the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
pav-kv committed Jun 18, 2021
1 parent c5f0ed5 commit 2a7670c
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions storage/cloudspanner/log_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,25 @@ func (ls *logStorage) readOnlyTX() *spanner.ReadOnlyTransaction {
return ls.ts.client.ReadOnlyTransaction().WithTimestampBound(staleness)
}

func (ls *logStorage) GetActiveLogIDs(ctx context.Context) ([]int64, error) {
ids := []int64{}
// We have to use SQL as Read() doesn't work against an index.
stmt := spanner.NewStatement(getActiveLogIDsSQL)
rows := ls.readOnlyTX().Query(ctx, stmt)
if err := rows.Do(func(r *spanner.Row) error {
var id int64
if err := r.Columns(&id); err != nil {
return err
}
ids = append(ids, id)
return nil
}); err != nil {
glog.Warningf("GetActiveLogIDs: %v", err)
return nil, fmt.Errorf("problem executing getActiveLogIDsSQL: %v", err)
}
return ids, nil
}

func newLogCache(tree *trillian.Tree) (*cache.SubtreeCache, error) {
return cache.NewLogSubtreeCache(rfc6962.DefaultHasher), nil
}
Expand Down Expand Up @@ -964,25 +983,6 @@ type QueuedEntry struct {
timestamp int64
}

func (ls *logStorage) GetActiveLogIDs(ctx context.Context) ([]int64, error) {
ids := []int64{}
// We have to use SQL as Read() doesn't work against an index.
stmt := spanner.NewStatement(getActiveLogIDsSQL)
rows := ls.readOnlyTX().Query(ctx, stmt)
if err := rows.Do(func(r *spanner.Row) error {
var id int64
if err := r.Columns(&id); err != nil {
return err
}
ids = append(ids, id)
return nil
}); err != nil {
glog.Warningf("GetActiveLogIDs: %v", err)
return nil, fmt.Errorf("problem executing getActiveLogIDsSQL: %v", err)
}
return ids, nil
}

// LogLeaf sorting boilerplate below.

type byIndex []*trillian.LogLeaf
Expand Down

0 comments on commit 2a7670c

Please sign in to comment.