aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-04-01 20:20:55 +0800
committerMaran <maran.hidskes@gmail.com>2014-04-01 20:20:55 +0800
commit0a8801082676d64f904cbb5b62c1159e0bbd7788 (patch)
tree05e9c4ea80d5e01cca53d583318f43606418a19e /ethutil
parent5f49a659c36dbfb8c330ddc3d4565c19a9a936b5 (diff)
parent7277c420479239fbea78417e42c43ee0162c2728 (diff)
downloadgo-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.tar.gz
go-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.tar.zst
go-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.zip
Merge conflicts
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/common.go1
-rw-r--r--ethutil/parsing.go2
-rw-r--r--ethutil/rlp.go2
-rw-r--r--ethutil/rlp_test.go5
-rw-r--r--ethutil/value.go9
5 files changed, 17 insertions, 2 deletions
diff --git a/ethutil/common.go b/ethutil/common.go
index f15b10e6d..c63af29a6 100644
--- a/ethutil/common.go
+++ b/ethutil/common.go
@@ -36,6 +36,7 @@ func CurrencyToString(num *big.Int) string {
var (
Big1 = big.NewInt(1)
+ Big2 = big.NewInt(1)
Big0 = big.NewInt(0)
Big256 = big.NewInt(0xff)
)
diff --git a/ethutil/parsing.go b/ethutil/parsing.go
index 8929f0829..16ed2d06d 100644
--- a/ethutil/parsing.go
+++ b/ethutil/parsing.go
@@ -131,7 +131,7 @@ func Instr(instr string) (int, []string, error) {
// Script compilation functions
// Compiles strings to machine code
-func Compile(instructions ...interface{}) (script []string) {
+func Assemble(instructions ...interface{}) (script []string) {
script = make([]string, len(instructions))
for i, val := range instructions {
diff --git a/ethutil/rlp.go b/ethutil/rlp.go
index 33ec0d359..e6c75696e 100644
--- a/ethutil/rlp.go
+++ b/ethutil/rlp.go
@@ -57,7 +57,7 @@ func DecodeWithReader(reader *bytes.Buffer) interface{} {
switch {
case char == 0:
return nil
- case char <= 0x7c:
+ case char <= 0x7f:
return char
case char <= 0xb7:
diff --git a/ethutil/rlp_test.go b/ethutil/rlp_test.go
index ce2535663..9e8127aab 100644
--- a/ethutil/rlp_test.go
+++ b/ethutil/rlp_test.go
@@ -129,6 +129,11 @@ func TestEncodeDecodeBytes(t *testing.T) {
}
}
+func TestEncodeZero(t *testing.T) {
+ b := NewValue(0).Encode()
+ fmt.Println(b)
+}
+
func BenchmarkEncodeDecode(b *testing.B) {
for i := 0; i < b.N; i++ {
bytes := Encode([]interface{}{"dog", "god", "cat"})
diff --git a/ethutil/value.go b/ethutil/value.go
index 46681ec2a..04131aba9 100644
--- a/ethutil/value.go
+++ b/ethutil/value.go
@@ -149,6 +149,15 @@ func (val *Value) IsStr() bool {
return val.Type() == reflect.String
}
+// Special list checking function. Something is considered
+// a list if it's of type []interface{}. The list is usually
+// used in conjunction with rlp decoded streams.
+func (val *Value) IsList() bool {
+ _, ok := val.Val.([]interface{})
+
+ return ok
+}
+
func (val *Value) IsEmpty() bool {
return val.Val == nil || ((val.IsSlice() || val.IsStr()) && val.Len() == 0)
}