aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-17 17:21:18 +0800
committerobscuren <geffobscura@gmail.com>2014-07-17 17:21:18 +0800
commited3424ff75b396360990725afc124326dea4ab45 (patch)
tree1d1bc85f1133d5138e3c23bfdadadce54d1354ec /ethutil
parent14c4f06100d9f06592097c4ee588d0f83f6b17bd (diff)
downloadgo-tangerine-ed3424ff75b396360990725afc124326dea4ab45.tar.gz
go-tangerine-ed3424ff75b396360990725afc124326dea4ab45.tar.zst
go-tangerine-ed3424ff75b396360990725afc124326dea4ab45.zip
Trie fixes
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/bytes.go12
-rw-r--r--ethutil/value.go8
2 files changed, 11 insertions, 9 deletions
diff --git a/ethutil/bytes.go b/ethutil/bytes.go
index 07584d0bf..d16bd6780 100644
--- a/ethutil/bytes.go
+++ b/ethutil/bytes.go
@@ -150,12 +150,16 @@ func LeftPadBytes(slice []byte, l int) []byte {
return padded
}
-func Address(slice []byte) []byte {
+func Address(slice []byte) (addr []byte) {
if len(slice) < 20 {
- slice = LeftPadBytes(slice, 20)
+ addr = LeftPadBytes(slice, 20)
} else if len(slice) > 20 {
- slice = slice[len(slice)-20:]
+ addr = slice[len(slice)-20:]
+ } else {
+ addr = slice
}
- return slice
+ addr = CopyBytes(addr)
+
+ return
}
diff --git a/ethutil/value.go b/ethutil/value.go
index ecb9d1511..fba7426d1 100644
--- a/ethutil/value.go
+++ b/ethutil/value.go
@@ -40,13 +40,9 @@ func (val *Value) Len() int {
//return val.kind.Len()
if data, ok := val.Val.([]interface{}); ok {
return len(data)
- } else if data, ok := val.Val.([]byte); ok {
- return len(data)
- } else if data, ok := val.Val.(string); ok {
- return len(data)
}
- return 0
+ return len(val.Bytes())
}
func (val *Value) Raw() interface{} {
@@ -118,6 +114,8 @@ func (val *Value) Bytes() []byte {
return []byte{s}
} else if s, ok := val.Val.(string); ok {
return []byte(s)
+ } else if s, ok := val.Val.(*big.Int); ok {
+ return s.Bytes()
}
return []byte{}