aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-25 02:40:40 +0800
committerobscuren <geffobscura@gmail.com>2014-09-25 02:40:40 +0800
commit1118aaf840a6f6b4dd6b137f39ab895a0cbd5a56 (patch)
treeae9b4ddf48556081ff4d3d3328dbc4227f4aa256
parent544b7fba7f2e826bc7c4eef016082b266d17e5f6 (diff)
downloaddexon-1118aaf840a6f6b4dd6b137f39ab895a0cbd5a56.tar.gz
dexon-1118aaf840a6f6b4dd6b137f39ab895a0cbd5a56.tar.zst
dexon-1118aaf840a6f6b4dd6b137f39ab895a0cbd5a56.zip
Temp work around
-rw-r--r--ethpipe/js_types.go7
-rw-r--r--ethutil/list.go19
2 files changed, 13 insertions, 13 deletions
diff --git a/ethpipe/js_types.go b/ethpipe/js_types.go
index 8d2805f3d..ccd585cf0 100644
--- a/ethpipe/js_types.go
+++ b/ethpipe/js_types.go
@@ -36,13 +36,6 @@ func NewJSBlock(block *ethchain.Block) *JSBlock {
ptxs = append(ptxs, *NewJSTx(tx))
}
- /*
- txJson, err := json.Marshal(ptxs)
- if err != nil {
- return nil
- }
- return &JSBlock{ref: block, Size: block.Size().String(), Number: int(block.Number.Uint64()), GasUsed: block.GasUsed.String(), GasLimit: block.GasLimit.String(), Hash: ethutil.Bytes2Hex(block.Hash()), Transactions: string(txJson), Time: block.Time, Coinbase: ethutil.Bytes2Hex(block.Coinbase)}
- */
list := ethutil.NewList(ptxs)
return &JSBlock{ref: block, Size: block.Size().String(), Number: int(block.Number.Uint64()), GasUsed: block.GasUsed.String(), GasLimit: block.GasLimit.String(), Hash: ethutil.Bytes2Hex(block.Hash()), Transactions: list, Time: block.Time, Coinbase: ethutil.Bytes2Hex(block.Coinbase)}
diff --git a/ethutil/list.go b/ethutil/list.go
index a5147573a..4fb36224f 100644
--- a/ethutil/list.go
+++ b/ethutil/list.go
@@ -2,7 +2,6 @@ package ethutil
import (
"encoding/json"
- "fmt"
"reflect"
)
@@ -10,6 +9,7 @@ import (
// for containing any slice type to use in an environment which
// does not support slice types (e.g., JavaScript, QML)
type List struct {
+ val interface{}
list reflect.Value
Length int
}
@@ -21,7 +21,7 @@ func NewList(t interface{}) *List {
panic("list container initialized with a non-slice type")
}
- return &List{list, list.Len()}
+ return &List{t, list, list.Len()}
}
func EmptyList() *List {
@@ -30,17 +30,24 @@ func EmptyList() *List {
// Get N element from the embedded slice. Returns nil if OOB.
func (self *List) Get(i int) interface{} {
- if self.list.Len() == 3 {
- fmt.Println("get", i, self.list.Index(i).Interface())
- }
if self.list.Len() > i {
- return self.list.Index(i).Interface()
+ i := self.list.Index(i).Interface()
+
+ return i
}
return nil
}
+func (self *List) GetAsJson(i int) interface{} {
+ e := self.Get(i)
+
+ r, _ := json.Marshal(e)
+
+ return string(r)
+}
+
// Appends value at the end of the slice. Panics when incompatible value
// is given.
func (self *List) Append(v interface{}) {