Fixed state object gas return

This commit is contained in:
obscuren
2014-05-28 23:16:54 +02:00
parent 73a42d34a5
commit 4d98762486
4 changed files with 43 additions and 8 deletions

View File

@ -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)
}