Skip to content

Commit

Permalink
Convert ReadDB to private interface
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya1702 committed Nov 8, 2024
1 parent 0be9cc5 commit ca4d6d6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/soroban-rpc/internal/db/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type LedgerWriter interface {
InsertLedger(ledger xdr.LedgerCloseMeta) error
}

type ReadDB interface {
type readDB interface {
Select(ctx context.Context, dest interface{}, query sq.Sqlizer) error
}

Expand Down Expand Up @@ -163,7 +163,7 @@ func (r ledgerReader) BatchGetLedgers(ctx context.Context, sequence uint32,
return batchGetLedgers(ctx, r.db, sequence, batchSize)
}

func batchGetLedgers(ctx context.Context, db ReadDB, sequence uint32,
func batchGetLedgers(ctx context.Context, db readDB, sequence uint32,
batchSize uint,
) ([]xdr.LedgerCloseMeta, error) {
sql := sq.Select("meta").
Expand Down Expand Up @@ -197,7 +197,7 @@ func (r ledgerReader) GetLedgerRange(ctx context.Context) (ledgerbucketwindow.Le

// getLedgerRangeWithCache uses the latest ledger cache to optimize the query.
// It only needs to look up the first ledger since we have the latest cached.
func getLedgerRangeWithCache(ctx context.Context, db ReadDB,
func getLedgerRangeWithCache(ctx context.Context, db readDB,
latestSeq uint32, latestTime int64,
) (ledgerbucketwindow.LedgerRange, error) {
query := sq.Select("meta").
Expand Down Expand Up @@ -227,7 +227,7 @@ func getLedgerRangeWithCache(ctx context.Context, db ReadDB,
}

// getLedgerRangeWithoutCache queries both the first and last ledger when cache isn't available
func getLedgerRangeWithoutCache(ctx context.Context, db ReadDB) (ledgerbucketwindow.LedgerRange, error) {
func getLedgerRangeWithoutCache(ctx context.Context, db readDB) (ledgerbucketwindow.LedgerRange, error) {
query := sq.Select("lcm.meta").
From(ledgerCloseMetaTableName + " as lcm").
Where(sq.Or{
Expand Down

0 comments on commit ca4d6d6

Please sign in to comment.