Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Aug 28, 2023
1 parent c544a0e commit 1eaeb86
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cmd/soroban-rpc/internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ func MustNew(cfg *config.Config) *Daemon {
// NOTE: We could optimize this to avoid unnecessary ingestion calls
// (the range of txmetads can be larger than the store retention windows)
// but it's probably not worth the pain.
err = db.NewLedgerReader(dbConn).StreamAllLedgers(readTxMetaCtx, func(txmeta xdr.LedgerCloseMeta) (bool, error) {
err = db.NewLedgerReader(dbConn).StreamAllLedgers(readTxMetaCtx, func(txmeta xdr.LedgerCloseMeta) error {
if err := eventStore.IngestEvents(txmeta); err != nil {
logger.WithError(err).Fatal("could not initialize event memory store")
}
if err := transactionStore.IngestTransactions(txmeta); err != nil {
logger.WithError(err).Fatal("could not initialize transaction memory store")
}
return false, nil
return nil
})
if err != nil {
logger.WithError(err).Fatal("could not obtain txmeta cache from the database")
Expand Down
8 changes: 2 additions & 6 deletions cmd/soroban-rpc/internal/db/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
ledgerCloseMetaTableName = "ledger_close_meta"
)

type StreamLedgerFn func(xdr.LedgerCloseMeta) (done bool, err error)
type StreamLedgerFn func(xdr.LedgerCloseMeta) error

type LedgerReader interface {
GetLedger(ctx context.Context, sequence uint32) (xdr.LedgerCloseMeta, bool, error)
Expand Down Expand Up @@ -45,13 +45,9 @@ func (r ledgerReader) StreamAllLedgers(ctx context.Context, f StreamLedgerFn) er
if err = q.Scan(&closeMeta); err != nil {
return err
}
done, err := f(closeMeta)
if err != nil {
if err = f(closeMeta); err != nil {
return err
}
if done {
return nil
}
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-rpc/internal/db/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func createLedger(ledgerSequence uint32) xdr.LedgerCloseMeta {

func assertLedgerRange(t *testing.T, reader LedgerReader, start, end uint32) {
var allLedgers []xdr.LedgerCloseMeta
err := reader.StreamAllLedgers(context.Background(), func(txmeta xdr.LedgerCloseMeta) (done bool, err error) {
err := reader.StreamAllLedgers(context.Background(), func(txmeta xdr.LedgerCloseMeta) error {
allLedgers = append(allLedgers, txmeta)
return false, nil
return nil
})
assert.NoError(t, err)
for i := start - 1; i <= end+1; i++ {
Expand Down

0 comments on commit 1eaeb86

Please sign in to comment.