forked from cerc-io/plugeth
Make use of new list type for transactions instead of json
This commit is contained in:
parent
a63b74e345
commit
0fea62ec6d
@ -1,7 +1,6 @@
|
|||||||
package ethpipe
|
package ethpipe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -13,16 +12,17 @@ import (
|
|||||||
|
|
||||||
// Block interface exposed to QML
|
// Block interface exposed to QML
|
||||||
type JSBlock struct {
|
type JSBlock struct {
|
||||||
|
//Transactions string `json:"transactions"`
|
||||||
ref *ethchain.Block
|
ref *ethchain.Block
|
||||||
Size string `json:"size"`
|
Size string `json:"size"`
|
||||||
Number int `json:"number"`
|
Number int `json:"number"`
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Transactions string `json:"transactions"`
|
Transactions *ethutil.List `json:"transactions"`
|
||||||
Time int64 `json:"time"`
|
Time int64 `json:"time"`
|
||||||
Coinbase string `json:"coinbase"`
|
Coinbase string `json:"coinbase"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
GasLimit string `json:"gasLimit"`
|
GasLimit string `json:"gasLimit"`
|
||||||
GasUsed string `json:"gasUsed"`
|
GasUsed string `json:"gasUsed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new QML Block from a chain block
|
// Creates a new QML Block from a chain block
|
||||||
@ -36,12 +36,16 @@ func NewJSBlock(block *ethchain.Block) *JSBlock {
|
|||||||
ptxs = append(ptxs, *NewJSTx(tx))
|
ptxs = append(ptxs, *NewJSTx(tx))
|
||||||
}
|
}
|
||||||
|
|
||||||
txJson, err := json.Marshal(ptxs)
|
/*
|
||||||
if err != nil {
|
txJson, err := json.Marshal(ptxs)
|
||||||
return nil
|
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: string(txJson), Time: block.Time, Coinbase: ethutil.Bytes2Hex(block.Coinbase)}
|
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)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSBlock) ToString() string {
|
func (self *JSBlock) ToString() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user