Skip to content

Commit

Permalink
moving to a better xeth
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Jan 28, 2015
1 parent b46e1ca commit 7f638f0
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 454 deletions.
4 changes: 3 additions & 1 deletion cmd/mist/assets/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ ApplicationWindow {

mainSplit.setView(wallet.view, wallet.menuItem);

newBrowserTab("http://etherian.io");
console.log(">>>>>>")
newBrowserTab("http://etherian.io");
console.log("WTF")

// Command setup
gui.sendCommand(0)
Expand Down
11 changes: 2 additions & 9 deletions cmd/mist/assets/qml/views/wallet.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Rectangle {
function setBalance() {
//balance.text = "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.key().address))
if(menuItem)
menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.key().address))
menuItem.secondaryTitle = eth.numberToHuman("0")
//menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.key().address))
}

ListModel {
Expand Down Expand Up @@ -155,14 +156,6 @@ Rectangle {
model: ListModel {
id: txModel
Component.onCompleted: {
var me = eth.key().address;
var filterTo = ethx.watch({latest: -1, to: me});
var filterFrom = ethx.watch({latest: -1, from: me});
filterTo.changed(addTxs)
filterFrom.changed(addTxs)

addTxs(filterTo.messages())
addTxs(filterFrom.messages())
}

function addTxs(messages) {
Expand Down
90 changes: 36 additions & 54 deletions cmd/mist/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"path"
"runtime"
"strconv"
"strings"
"time"

"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -229,41 +228,44 @@ func (gui *Gui) setInitialChain(ancientBlocks bool) {
}

func (gui *Gui) loadAddressBook() {
view := gui.getObjectByName("infoView")
nameReg := gui.xeth.World().Config().Get("NameReg")
if nameReg != nil {
it := nameReg.Trie().Iterator()
for it.Next() {
if it.Key[0] != 0 {
view.Call("addAddress", struct{ Name, Address string }{string(it.Key), ethutil.Bytes2Hex(it.Value)})
}
/*
view := gui.getObjectByName("infoView")
nameReg := gui.xeth.World().Config().Get("NameReg")
if nameReg != nil {
it := nameReg.Trie().Iterator()
for it.Next() {
if it.Key[0] != 0 {
view.Call("addAddress", struct{ Name, Address string }{string(it.Key), ethutil.Bytes2Hex(it.Value)})
}
}
}
}
*/
}

func (self *Gui) loadMergedMiningOptions() {
view := self.getObjectByName("mergedMiningModel")

mergeMining := self.xeth.World().Config().Get("MergeMining")
if mergeMining != nil {
i := 0
it := mergeMining.Trie().Iterator()
for it.Next() {
view.Call("addMergedMiningOption", struct {
Checked bool
Name, Address string
Id, ItemId int
}{false, string(it.Key), ethutil.Bytes2Hex(it.Value), 0, i})

i++
/*
view := self.getObjectByName("mergedMiningModel")
mergeMining := self.xeth.World().Config().Get("MergeMining")
if mergeMining != nil {
i := 0
it := mergeMining.Trie().Iterator()
for it.Next() {
view.Call("addMergedMiningOption", struct {
Checked bool
Name, Address string
Id, ItemId int
}{false, string(it.Key), ethutil.Bytes2Hex(it.Value), 0, i})
i++
}
}
}
*/
}

func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
nameReg := gui.xeth.World().Config().Get("NameReg")
addr := gui.address()

var inout string
Expand All @@ -275,31 +277,11 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {

var (
ptx = xeth.NewJSTx(tx)
send = nameReg.Storage(tx.From())
rec = nameReg.Storage(tx.To())
s, r string
send = ethutil.Bytes2Hex(tx.From())
rec = ethutil.Bytes2Hex(tx.To())
)

if core.MessageCreatesContract(tx) {
rec = nameReg.Storage(core.AddressFromMessage(tx))
}

if send.Len() != 0 {
s = strings.Trim(send.Str(), "\x00")
} else {
s = ethutil.Bytes2Hex(tx.From())
}
if rec.Len() != 0 {
r = strings.Trim(rec.Str(), "\x00")
} else {
if core.MessageCreatesContract(tx) {
r = ethutil.Bytes2Hex(core.AddressFromMessage(tx))
} else {
r = ethutil.Bytes2Hex(tx.To())
}
}
ptx.Sender = s
ptx.Address = r
ptx.Sender = send
ptx.Address = rec

if window == "post" {
//gui.getObjectByName("transactionView").Call("addTx", ptx, inout)
Expand All @@ -320,7 +302,7 @@ func (gui *Gui) readPreviousTransactions() {
}

func (gui *Gui) processBlock(block *types.Block, initial bool) {
name := strings.Trim(gui.xeth.World().Config().Get("NameReg").Storage(block.Coinbase()).Str(), "\x00")
name := ethutil.Bytes2Hex(block.Coinbase())
b := xeth.NewJSBlock(block)
b.Name = name

Expand Down Expand Up @@ -531,9 +513,9 @@ NumGC: %d
func (gui *Gui) setPeerInfo() {
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
gui.win.Root().Call("resetPeers")
for _, peer := range gui.xeth.Peers() {
gui.win.Root().Call("addPeer", peer)
}
//for _, peer := range gui.xeth.Peers() {
//gui.win.Root().Call("addPeer", peer)
//}
}

func (gui *Gui) privateKey() string {
Expand Down
54 changes: 0 additions & 54 deletions cmd/mist/ui_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@
package main

import (
"bytes"
"fmt"
"path"
"strconv"
"strings"

"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event/filter"
Expand Down Expand Up @@ -79,56 +75,6 @@ func (self *UiLib) Notef(args []interface{}) {
guilogger.Infoln(args...)
}

func (self *UiLib) LookupDomain(domain string) string {
world := self.World()

if len(domain) > 32 {
domain = string(crypto.Sha3([]byte(domain)))
}
data := world.Config().Get("DnsReg").StorageString(domain).Bytes()

// Left padded = A record, Right padded = CNAME
if len(data) > 0 && data[0] == 0 {
data = bytes.TrimLeft(data, "\x00")
var ipSlice []string
for _, d := range data {
ipSlice = append(ipSlice, strconv.Itoa(int(d)))
}

return strings.Join(ipSlice, ".")
} else {
data = bytes.TrimRight(data, "\x00")

return string(data)
}
}

func (self *UiLib) LookupName(addr string) string {
var (
nameReg = self.World().Config().Get("NameReg")
lookup = nameReg.Storage(ethutil.Hex2Bytes(addr))
)

if lookup.Len() != 0 {
return strings.Trim(lookup.Str(), "\x00")
}

return addr
}

func (self *UiLib) LookupAddress(name string) string {
var (
nameReg = self.World().Config().Get("NameReg")
lookup = nameReg.Storage(ethutil.RightPadBytes([]byte(name), 32))
)

if lookup.Len() != 0 {
return ethutil.Bytes2Hex(lookup.Bytes())
}

return ""
}

func (self *UiLib) PastPeers() *ethutil.List {
return ethutil.NewList([]string{})
//return ethutil.NewList(eth.PastPeers())
Expand Down
2 changes: 1 addition & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func GenesisBlock(db ethutil.Database) *types.Block {
statedb := state.New(genesis.Root(), db)
//statedb := state.New(genesis.Trie())
for _, addr := range []string{
"51ba59315b3a95761d0863b05ccc7a7f54703d99",
"dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6",
"e4157b34ea9615cfbde6b4fda419828124b70c78",
"b9c015918bdaba24b4ff057a92a3873d6eb201be",
"6c386a4b26f73c802f34673f7248bb118f97424a",
Expand Down
4 changes: 4 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ func (s *Ethereum) MaxPeers() int {
return s.net.MaxPeers
}

func (s *Ethereum) Coinbase() []byte {
return nil // TODO
}

// Start the ethereum
func (s *Ethereum) Start(seed bool) error {
err := s.net.Start()
Expand Down
10 changes: 1 addition & 9 deletions javascript/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,8 @@ func (self *JSEthereum) Block(v interface{}) otto.Value {
return otto.UndefinedValue()
}

func (self *JSEthereum) Peers() otto.Value {
return self.toVal(self.JSXEth.Peers())
}

func (self *JSEthereum) Key() otto.Value {
return self.toVal(self.JSXEth.Key())
}

func (self *JSEthereum) GetStateObject(addr string) otto.Value {
return self.toVal(&JSStateObject{xeth.NewJSObject(self.JSXEth.World().SafeGet(ethutil.Hex2Bytes(addr))), self})
return self.toVal(&JSStateObject{xeth.NewJSObject(self.JSXEth.State().SafeGet(addr)), self})
}

func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value {
Expand Down
2 changes: 2 additions & 0 deletions rpc/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func (s *RpcHttpServer) Start() {

func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler {
fn := func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")

rpchttplogger.Debugln("Handling request")

reqParsed, reqerr := JSON.ParseRequestBody(req)
Expand Down
Loading

0 comments on commit 7f638f0

Please sign in to comment.