Skip to content

Commit

Permalink
Add getLedgers
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya1702 committed Apr 15, 2024
1 parent 6aa348d commit 7928c78
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/soroban-rpc/internal/db/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,18 @@ func (r ledgerReader) GetLedger(ctx context.Context, sequence uint32) (xdr.Ledge
}

func (r ledgerReader) GetLedgers(ctx context.Context, startSequence uint32, endSequence uint32) ([]xdr.LedgerCloseMeta, error) {
return []xdr.LedgerCloseMeta{}, nil
sql := sq.Select("meta").
From(ledgerCloseMetaTableName).
Where(
sq.And{
sq.GtOrEq{"sequence": startSequence},
sq.LtOrEq{"sequence": endSequence},
})
var results []xdr.LedgerCloseMeta
if err := r.db.Select(ctx, &results, sql); err != nil {

Check failure on line 82 in cmd/soroban-rpc/internal/db/ledger.go

View workflow job for this annotation

GitHub Actions / golangci

r.db.Select undefined (type *DB has no field or method Select) (typecheck)
return []xdr.LedgerCloseMeta{}, err
}
return results, nil
}

type ledgerWriter struct {
Expand Down
15 changes: 15 additions & 0 deletions cmd/soroban-rpc/internal/transactions/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ func (c Cursor) UnmarshalJSON(b []byte) error {
// 1 is returned if c is greater than other.
// -1 is returned if c is less than other.
func (c Cursor) Cmp(other interfaces.Cursor) int {
otherCursor := other.(*Cursor)

if c.LedgerSequence == otherCursor.LedgerSequence {
return cmp(c.TxIdx, otherCursor.TxIdx)
}
return cmp(c.LedgerSequence, otherCursor.LedgerSequence)
}

func cmp(a, b uint32) int {
if a < b {
return -1
}
if a > b {
return 1
}
return 0
}

Expand Down

0 comments on commit 7928c78

Please sign in to comment.