aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-29 05:16:54 +0800
committerobscuren <geffobscura@gmail.com>2014-05-29 05:16:54 +0800
commit4d987624867fc02a079d8355c28bad620db85f06 (patch)
tree967b2e6b8241642af207667c5db7fab00701cd3b /ethutil
parent73a42d34a5a58a634fd778858287a55a6af7537e (diff)
downloadgo-tangerine-4d987624867fc02a079d8355c28bad620db85f06.tar.gz
go-tangerine-4d987624867fc02a079d8355c28bad620db85f06.tar.zst
go-tangerine-4d987624867fc02a079d8355c28bad620db85f06.zip
Fixed state object gas return
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/bytes.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/ethutil/bytes.go b/ethutil/bytes.go
index 1c7a43af8..bd0df68ec 100644
--- a/ethutil/bytes.go
+++ b/ethutil/bytes.go
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"fmt"
+ "math/big"
)
// Number to bytes
@@ -98,3 +99,20 @@ func StringToByteFunc(str string, cb func(str string) []byte) (ret []byte) {
return
}
+
+func FormatData(data string) []byte {
+ if len(data) == 0 {
+ return nil
+ }
+ // Simple stupid
+ d := new(big.Int)
+ if data[0:1] == "\"" && data[len(data)-1:] == "\"" {
+ d.SetBytes([]byte(data[1 : len(data)-1]))
+ } else if len(data) > 1 && data[:2] == "0x" {
+ d.SetBytes(FromHex(data[2:]))
+ } else {
+ d.SetString(data, 0)
+ }
+
+ return BigToBytes(d, 256)
+}