Skip to content

Commit

Permalink
DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
IronGauntlets committed Jan 15, 2025
1 parent 035a5f5 commit 5859fac
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions rpc/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/NethermindEth/juno/blockchain"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/db"
"github.com/NethermindEth/juno/jsonrpc"
"github.com/NethermindEth/juno/starknet"
"github.com/NethermindEth/juno/sync"
Expand Down Expand Up @@ -141,19 +142,7 @@ func (h *Handler) traceTransaction(ctx context.Context, hash *felt.Felt) (*vm.Tr
httpHeader := http.Header{}
httpHeader.Set(ExecutionStepsHeader, "0")

if err != nil {
if pendingB := h.syncReader.PendingBlock(); pendingB != nil {
txIndex := slices.IndexFunc(pendingB.Transactions, func(tx core.Transaction) bool {
return tx.Hash().Equal(hash)
})
if txIndex != -1 {
traceResults, header, traceBlockErr := h.traceBlockTransactions(ctx, pendingB)
if traceBlockErr != nil {
return nil, header, traceBlockErr
}
return traceResults[txIndex].TraceRoot, header, nil
}
}
if err != nil && !errors.Is(err, db.ErrKeyNotFound) {
return nil, httpHeader, ErrTxnHashNotFound
}

Expand Down

0 comments on commit 5859fac

Please sign in to comment.