Skip to content

Commit

Permalink
Rename interfaces to avoid overloading 'Transaction' term
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Apr 24, 2024
1 parent f265e19 commit ed23473
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions cmd/soroban-rpc/internal/db/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ type TransactionWriter interface {
RegisterMetrics(ingest, insert, count prometheus.Observer)
}

// TransactionReader is used to serve requests and just returns a cloned,
// TransactionDbReader is used to serve requests and just returns a cloned,
// read-only DB session to perform actual DB reads on.
type TransactionReader interface {
NewTx(ctx context.Context) (TransactionReaderTx, error)
type TransactionDbReader interface {
NewTx(ctx context.Context) (TransactionReader, error)
}

// TransactionReaderTx provides all of the public ways to read from the DB.
// TransactionReader provides all of the public ways to read from the DB.
// Note that `Done()` *MUST* be called to clean things up.
type TransactionReaderTx interface {
type TransactionReader interface {
GetTransaction(hash xdr.Hash) (Transaction, ledgerbucketwindow.LedgerRange, error)
GetLedgerRange() (ledgerbucketwindow.LedgerRange, error)
Done() error
Expand All @@ -69,7 +69,7 @@ type transactionReaderTx struct {
passphrase string
}

func NewTransactionReader(db db.SessionInterface, passphrase string) TransactionReader {
func NewTransactionReader(db db.SessionInterface, passphrase string) TransactionDbReader {
return &transactionHandler{db: db, passphrase: passphrase}
}

Expand Down Expand Up @@ -159,7 +159,7 @@ func (txn *transactionHandler) trimTransactions(latestLedgerSeq uint32, retentio

// NewTx creates a read-only SQL transaction on a cloned database session. You
// MUST call `.Done()` on the resulting reader if there are no errors.
func (txn *transactionHandler) NewTx(ctx context.Context) (TransactionReaderTx, error) {
func (txn *transactionHandler) NewTx(ctx context.Context) (TransactionReader, error) {
sesh := txn.db.Clone()
if err := sesh.BeginTx(ctx, &sql.TxOptions{ReadOnly: true}); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-rpc/internal/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (h Handler) Close() {

type HandlerParams struct {
EventStore *events.MemoryStore
TransactionReader db.TransactionReader
TransactionReader db.TransactionDbReader
LedgerEntryReader db.LedgerEntryReader
LedgerReader db.LedgerReader
Logger *log.Entry
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-rpc/internal/methods/get_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type GetTransactionRequest struct {
func GetTransaction(
ctx context.Context,
log *log.Entry,
txGetter db.TransactionReader,
txGetter db.TransactionDbReader,
request GetTransactionRequest,
) (GetTransactionResponse, error) {
// parse hash
Expand Down Expand Up @@ -135,7 +135,7 @@ func GetTransaction(
}

// NewGetTransactionHandler returns a get transaction json rpc handler
func NewGetTransactionHandler(logger *log.Entry, getter db.TransactionReader) jrpc2.Handler {
func NewGetTransactionHandler(logger *log.Entry, getter db.TransactionDbReader) jrpc2.Handler {
return NewHandler(func(ctx context.Context, request GetTransactionRequest) (GetTransactionResponse, error) {
return GetTransaction(ctx, logger, getter, request)
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-rpc/internal/methods/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type HealthCheckResult struct {
// NewHealthCheck returns a health check json rpc handler
func NewHealthCheck(
retentionWindow uint32,
txReader db.TransactionReader,
txReader db.TransactionDbReader,
maxHealthyLedgerLatency time.Duration,
) jrpc2.Handler {
return NewHandler(func(ctx context.Context) (HealthCheckResult, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-rpc/internal/methods/send_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type SendTransactionRequest struct {
func NewSendTransactionHandler(
daemon interfaces.Daemon,
logger *log.Entry,
txReader db.TransactionReader,
txReader db.TransactionDbReader,
passphrase string,
) jrpc2.Handler {
submitter := daemon.CoreClient()
Expand Down

0 comments on commit ed23473

Please sign in to comment.