Skip to content

Commit

Permalink
Use cache value for getting latest ledger sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya1702 committed Aug 1, 2024
1 parent 3928831 commit db7c584
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/soroban-rpc/internal/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func getMetaValue(ctx context.Context, q db.SessionInterface, key string) (strin
}

func getLatestLedgerSequence(ctx context.Context, ledgerReader LedgerReader, cache *dbCache) (uint32, error) {
if cache.latestLedgerSeq != 0 {
return cache.latestLedgerSeq, nil
}

ledgerRange, err := ledgerReader.GetLedgerRange(ctx)
if err != nil {
return 0, err
Expand Down

0 comments on commit db7c584

Please sign in to comment.