Skip to content

Commit

Permalink
Use reader.Seek() - 2
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya1702 committed Apr 16, 2024
1 parent f813d01 commit 0e8b9da
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cmd/soroban-rpc/internal/methods/get_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,30 @@ LedgerLoop:
}
}

// Initialise tx reader and move it to start idx.
// Initialise tx reader.
reader, err := ingest.NewLedgerTransactionReaderFromLedgerCloseMeta(h.networkPassphrase, ledger)
if err != nil {
return GetTransactionsResponse{}, &jrpc2.Error{
Code: jrpc2.InvalidParams,
Message: err.Error(),
}
}
err = reader.Seek(int(start.TxIdx))

// Move the reader to specific tx idx
startTxIdx := 0
if ledgerSeq == start.LedgerSequence {
startTxIdx = int(start.TxIdx)
}
err = reader.Seek(startTxIdx)
if err != nil {
return GetTransactionsResponse{}, &jrpc2.Error{
Code: jrpc2.InvalidParams,
Message: err.Error(),
}
// Seek returns EOF so we can move onto next ledger
continue
}

// Decode transaction info from ledger meta
txCount := ledger.CountTransactions()
for i := start.TxIdx; i < uint32(txCount); i++ {
cursor = transactions.NewCursor(ledger.LedgerSequence(), i, 0)
for i := startTxIdx; i < txCount; i++ {
cursor = transactions.NewCursor(ledger.LedgerSequence(), uint32(i), 0)

tx, err := reader.Read()
if err != nil {
Expand Down

0 comments on commit 0e8b9da

Please sign in to comment.