aboutsummaryrefslogtreecommitdiffstats
path: root/common/bytes.go
diff options
context:
space:
mode:
authorzsfelfoldi <zsfelfoldi@gmail.com>2015-04-03 23:37:59 +0800
committerzelig <viktor.tron@gmail.com>2015-04-20 03:57:49 +0800
commite2d333d2095edb349388433c28f4d6a381b1df62 (patch)
tree2bc2dbf45ffeb1de93606122d263913d790d048f /common/bytes.go
parentac0e5e8b6de43a40bbc25f541aa2399202bbe420 (diff)
downloadgo-tangerine-e2d333d2095edb349388433c28f4d6a381b1df62.tar
go-tangerine-e2d333d2095edb349388433c28f4d6a381b1df62.tar.gz
go-tangerine-e2d333d2095edb349388433c28f4d6a381b1df62.tar.bz2
go-tangerine-e2d333d2095edb349388433c28f4d6a381b1df62.tar.lz
go-tangerine-e2d333d2095edb349388433c28f4d6a381b1df62.tar.xz
go-tangerine-e2d333d2095edb349388433c28f4d6a381b1df62.tar.zst
go-tangerine-e2d333d2095edb349388433c28f4d6a381b1df62.zip
NatSpec contracts in genesis block, end to end test (unfinished)
Diffstat (limited to 'common/bytes.go')
-rw-r--r--common/bytes.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/common/bytes.go b/common/bytes.go
index 5bdacd810..5d1245107 100644
--- a/common/bytes.go
+++ b/common/bytes.go
@@ -147,6 +147,23 @@ func Hex2Bytes(str string) []byte {
return h
}
+func Hex2BytesFixed(str string, flen int) []byte {
+
+ h, _ := hex.DecodeString(str)
+ if len(h) == flen {
+ return h
+ } else {
+ if len(h) > flen {
+ return h[len(h)-flen : len(h)]
+ } else {
+ hh := make([]byte, flen)
+ copy(hh[flen-len(h):flen], h[:])
+ return hh
+ }
+ }
+
+}
+
func StringToByteFunc(str string, cb func(str string) []byte) (ret []byte) {
if len(str) > 1 && str[0:2] == "0x" && !strings.Contains(str, "\n") {
ret = Hex2Bytes(str[2:])