mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
Update bytes.go
This commit is contained in:
parent
da548126ba
commit
72f3bfd838
1 changed files with 1 additions and 6 deletions
|
|
@ -27,7 +27,7 @@ import (
|
||||||
// FromHex returns the bytes represented by the hexadecimal string s.
|
// FromHex returns the bytes represented by the hexadecimal string s.
|
||||||
// s may be prefixed with "0x".
|
// s may be prefixed with "0x".
|
||||||
func FromHex(s string) []byte {
|
func FromHex(s string) []byte {
|
||||||
if has0xPrefix(s) {
|
if hexutil.Has0xPrefix(s) {
|
||||||
s = s[2:]
|
s = s[2:]
|
||||||
}
|
}
|
||||||
if len(s)%2 == 1 {
|
if len(s)%2 == 1 {
|
||||||
|
|
@ -47,11 +47,6 @@ func CopyBytes(b []byte) (copiedBytes []byte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// has0xPrefix validates str begins with '0x' or '0X'.
|
|
||||||
func has0xPrefix(str string) bool {
|
|
||||||
return len(str) >= 2 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')
|
|
||||||
}
|
|
||||||
|
|
||||||
// isHexCharacter returns bool of c being a valid hexadecimal.
|
// isHexCharacter returns bool of c being a valid hexadecimal.
|
||||||
func isHexCharacter(c byte) bool {
|
func isHexCharacter(c byte) bool {
|
||||||
return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')
|
return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue