mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
rpc: make BlockNumber a fmt.Stringer
This commit is contained in:
parent
5309cd73cb
commit
aa70048e50
1 changed files with 12 additions and 0 deletions
12
rpc/types.go
12
rpc/types.go
|
|
@ -23,6 +23,7 @@ import (
|
|||
"math"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
|
|
@ -275,6 +276,17 @@ func (bn BlockNumber) Int64() int64 {
|
|||
return (int64)(bn)
|
||||
}
|
||||
|
||||
func (bn BlockNumber) String() string {
|
||||
switch bn {
|
||||
case PendingBlockNumber:
|
||||
return "pending"
|
||||
case LatestBlockNumber:
|
||||
return "latest"
|
||||
default:
|
||||
return "0x" + strconv.FormatInt(int64(bn), 16)
|
||||
}
|
||||
}
|
||||
|
||||
// HexBytes JSON-encodes as hex with 0x prefix.
|
||||
type HexBytes []byte
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue