ethclient: return uint64 in BlockNumberByTransactionHash

This commit is contained in:
Jean-André Santoni 2018-01-10 21:48:33 +07:00
parent eab15200c2
commit b406147c49

View file

@ -23,6 +23,7 @@ import (
"errors"
"fmt"
"math/big"
"strconv"
"github.com/ethereum/go-ethereum"
"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.
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
err = ec.c.CallContext(ctx, &json, "eth_getTransactionByHash", hash)
if err != nil {
return nil, err
return 0, err
} else if json == nil {
return nil, ethereum.NotFound
return 0, ethereum.NotFound
} 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)
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