本文整理匯總了Golang中github.com/ethereum/go-ethereum/common.IsHex函數的典型用法代碼示例。如果您正苦於以下問題:Golang IsHex函數的具體用法?Golang IsHex怎麽用?Golang IsHex使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了IsHex函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FromNumber
func (self *XEth) FromNumber(str string) string {
if common.IsHex(str) {
str = str[2:]
}
return common.BigD(common.FromHex(str)).String()
}
示例2: FromAscii
func (self *XEth) FromAscii(str string) string {
if common.IsHex(str) {
str = str[2:]
}
return string(bytes.Trim(common.FromHex(str), "\x00"))
}
示例3: StorageString
func (self *Object) StorageString(str string) *common.Value {
if common.IsHex(str) {
return self.storage(common.Hex2Bytes(str[2:]))
} else {
return self.storage(common.RightPadBytes([]byte(str), 32))
}
}
示例4: FromHex
func FromHex(h string) []byte {
if common.IsHex(h) {
h = h[2:]
}
return common.Hex2Bytes(h)
}
示例5: StateObjectFromAccount
func StateObjectFromAccount(db common.Database, addr string, account Account) *state.StateObject {
obj := state.NewStateObject(common.HexToAddress(addr), db)
obj.SetBalance(common.Big(account.Balance))
if common.IsHex(account.Code) {
account.Code = account.Code[2:]
}
obj.SetCode(common.Hex2Bytes(account.Code))
obj.SetNonce(common.Big(account.Nonce).Uint64())
return obj
}
示例6: mapToTxParams
func mapToTxParams(object map[string]interface{}) map[string]string {
// Default values
if object["from"] == nil {
object["from"] = ""
}
if object["to"] == nil {
object["to"] = ""
}
if object["value"] == nil {
object["value"] = ""
}
if object["gas"] == nil {
object["gas"] = ""
}
if object["gasPrice"] == nil {
object["gasPrice"] = ""
}
var dataStr string
var data []string
if list, ok := object["data"].(*qml.List); ok {
list.Convert(&data)
} else if str, ok := object["data"].(string); ok {
data = []string{str}
}
for _, str := range data {
if common.IsHex(str) {
str = str[2:]
if len(str) != 64 {
str = common.LeftPadString(str, 64)
}
} else {
str = common.Bytes2Hex(common.LeftPadBytes(common.Big(str).Bytes(), 32))
}
dataStr += str
}
object["data"] = dataStr
conv := make(map[string]string)
for key, value := range object {
if v, ok := value.(string); ok {
conv[key] = v
}
}
return conv
}