Skip to content

Commit

Permalink
If tx not found, return "result": null like solana does
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Feb 20, 2024
1 parent 71a3914 commit 5059d87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion multiepoch-getTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (multi *MultiEpoch) handleGetTransaction(ctx context.Context, conn *request
epochNumber, err := multi.findEpochNumberFromSignature(ctx, sig)
if err != nil {
if errors.Is(err, ErrNotFound) {
// TODO: solana just returns null here in case of transaction not found: {"jsonrpc":"2.0","result":null,"id":1}
// solana just returns null here in case of transaction not found: {"jsonrpc":"2.0","result":null,"id":1}
return &jsonrpc2.Error{
Code: CodeNotFound,
Message: "Transaction not found",
Expand Down
20 changes: 15 additions & 5 deletions multiepoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"fmt"
"net/http"
"sort"
Expand Down Expand Up @@ -401,11 +402,20 @@ func newMultiEpochHandler(handler *MultiEpoch, lsConf *ListenerConfig) func(ctx
metrics_methodToNumProxied.WithLabelValues(sanitizeMethod(method)).Inc()
return
} else {
rqCtx.ReplyWithError(
reqCtx,
rpcRequest.ID,
errorResp,
)
if errors.Is(err, ErrNotFound) {
// reply with null result
rqCtx.ReplyRaw(
reqCtx,
rpcRequest.ID,
nil,
)
} else {
rqCtx.ReplyWithError(
reqCtx,
rpcRequest.ID,
errorResp,
)
}
}
return
}
Expand Down

0 comments on commit 5059d87

Please sign in to comment.