mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
ethclient: return uint64 in BlockNumberByTransactionHash
This commit is contained in:
parent
eab15200c2
commit
b406147c49
1 changed files with 10 additions and 5 deletions
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -194,18 +195,22 @@ func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockNumberByTransactionHash returns block number for the transaction with the given hash.
|
// BlockNumberByTransactionHash returns block number for the transaction with the given hash.
|
||||||
func (ec *Client) BlockNumberByTransactionHash(ctx context.Context, hash common.Hash) (blockNumber *string, err error) {
|
func (ec *Client) BlockNumberByTransactionHash(ctx context.Context, hash common.Hash) (blockNumber uint64, err error) {
|
||||||
var json *rpcTransaction
|
var json *rpcTransaction
|
||||||
err = ec.c.CallContext(ctx, &json, "eth_getTransactionByHash", hash)
|
err = ec.c.CallContext(ctx, &json, "eth_getTransactionByHash", hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return 0, err
|
||||||
} else if json == nil {
|
} else if json == nil {
|
||||||
return nil, ethereum.NotFound
|
return 0, ethereum.NotFound
|
||||||
} else if _, r, _ := json.tx.RawSignatureValues(); r == nil {
|
} else if _, r, _ := json.tx.RawSignatureValues(); r == nil {
|
||||||
return nil, fmt.Errorf("server returned transaction without signature")
|
return 0, fmt.Errorf("server returned transaction without signature")
|
||||||
}
|
}
|
||||||
setSenderFromServer(json.tx, json.From, json.BlockHash)
|
setSenderFromServer(json.tx, json.From, json.BlockHash)
|
||||||
return json.BlockNumber, nil
|
blockNumber, err = strconv.ParseUint(*json.BlockNumber, 0, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return blockNumber, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionSender returns the sender address of the given transaction. The transaction
|
// TransactionSender returns the sender address of the given transaction. The transaction
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue