aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-11 22:23:38 +0800
committerobscuren <geffobscura@gmail.com>2014-08-11 22:23:38 +0800
commita760ce05b948e89bc564af20599dcf95698ac0eb (patch)
treee9a1f0161521bc895de45e683ba6904a0d4923f9 /ethutil
parent2e5d28c73f1d97865def3ffe8c7ad0a4819f15f3 (diff)
downloadgo-tangerine-a760ce05b948e89bc564af20599dcf95698ac0eb.tar.gz
go-tangerine-a760ce05b948e89bc564af20599dcf95698ac0eb.tar.zst
go-tangerine-a760ce05b948e89bc564af20599dcf95698ac0eb.zip
Updated chain for filtering
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/rlp.go9
-rw-r--r--ethutil/value.go24
2 files changed, 29 insertions, 4 deletions
diff --git a/ethutil/rlp.go b/ethutil/rlp.go
index cf7f97ffd..17ff627eb 100644
--- a/ethutil/rlp.go
+++ b/ethutil/rlp.go
@@ -2,15 +2,16 @@ package ethutil
import (
"bytes"
- _ "encoding/binary"
"fmt"
- _ "log"
- _ "math"
"math/big"
)
-type RlpEncodable interface {
+type RlpEncode interface {
RlpEncode() []byte
+}
+
+type RlpEncodeDecode interface {
+ RlpEncode
RlpValue() []interface{}
}
diff --git a/ethutil/value.go b/ethutil/value.go
index 2233b978c..608d332ba 100644
--- a/ethutil/value.go
+++ b/ethutil/value.go
@@ -74,6 +74,30 @@ func (val *Value) Uint() uint64 {
return 0
}
+func (val *Value) Int() int64 {
+ if Val, ok := val.Val.(int8); ok {
+ return int64(Val)
+ } else if Val, ok := val.Val.(int16); ok {
+ return int64(Val)
+ } else if Val, ok := val.Val.(int32); ok {
+ return int64(Val)
+ } else if Val, ok := val.Val.(int64); ok {
+ return Val
+ } else if Val, ok := val.Val.(int); ok {
+ return int64(Val)
+ } else if Val, ok := val.Val.(float32); ok {
+ return int64(Val)
+ } else if Val, ok := val.Val.(float64); ok {
+ return int64(Val)
+ } else if Val, ok := val.Val.([]byte); ok {
+ return new(big.Int).SetBytes(Val).Int64()
+ } else if Val, ok := val.Val.(*big.Int); ok {
+ return Val.Int64()
+ }
+
+ return 0
+}
+
func (val *Value) Byte() byte {
if Val, ok := val.Val.(byte); ok {
return Val