Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wmitsuda committed Dec 16, 2024
1 parent 7ae643e commit 610cf5e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions turbo/jsonrpc/otterscan_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type OtterscanAPI interface {
GetTransactionError(ctx context.Context, hash common.Hash) (hexutility.Bytes, error)
GetTransactionBySenderAndNonce(ctx context.Context, addr common.Address, nonce uint64) (*common.Hash, error)
GetContractCreator(ctx context.Context, addr common.Address) (*ContractCreatorData, error)

// TODO: remove test
TxNum2Block(ctx context.Context, txNum uint64) (uint64, error)
}

type OtterscanAPIImpl struct {
Expand All @@ -83,6 +86,24 @@ func NewOtterscanAPI(base *BaseAPI, db kv.TemporalRoDB, maxPageSize uint64) *Ott
}
}

func (api *OtterscanAPIImpl) TxNum2Block(ctx context.Context, txNum uint64) (uint64, error) {
tx, err := api.db.BeginTemporalRo(ctx)
if err != nil {
return 0, err
}
defer tx.Rollback()

ok, blockNum, err := rawdbv3.TxNums.FindBlockNum(tx, txNum)
if !ok {
return 0, nil
}
if err != nil {
return 0, err
}

return blockNum, nil
}

func (api *OtterscanAPIImpl) GetApiLevel() uint8 {
return API_LEVEL
}
Expand Down

0 comments on commit 610cf5e

Please sign in to comment.