From bdf99e098126880c10dc2ef68623c47ec6f04537 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Wed, 21 Jan 2015 10:17:07 -0600 Subject: Add LogFormat flag --- cmd/ethereum/flags.go | 2 ++ cmd/ethereum/main.go | 1 + 2 files changed, 3 insertions(+) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index f829744dc..885cdfe5b 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -57,6 +57,7 @@ var ( ConfigFile string DebugFile string LogLevel int + LogFormat string Dump bool DumpHash string DumpNumber int @@ -110,6 +111,7 @@ func Init() { flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") + flag.StringVar(&LogFormat, "logformat", "std", "logformat: std,raw)") flag.BoolVar(&DiffTool, "difftool", false, "creates output for diff'ing. Sets LogLevel=0") flag.StringVar(&DiffType, "diff", "all", "sets the level of diff output [vm, all]. Has no effect if difftool=false") flag.BoolVar(&ShowGenesis, "genesis", false, "Dump the genesis block") diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index b816c678e..b7997d485 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -67,6 +67,7 @@ func main() { DataDir: Datadir, LogFile: LogFile, LogLevel: LogLevel, + LogFormat: LogFormat, Identifier: Identifier, MaxPeers: MaxPeer, Port: OutboundPort, -- cgit v1.2.3 From 9d2166a964d83c09481dea6ef30889f260249295 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 5 Feb 2015 08:29:41 -0800 Subject: wip --- cmd/mist/assets/examples/coin.html | 20 +++--- cmd/mist/assets/html/home.html | 142 ++++++++++++++++++------------------- 2 files changed, 81 insertions(+), 81 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/examples/coin.html b/cmd/mist/assets/examples/coin.html index a84a828af..9d1a83171 100644 --- a/cmd/mist/assets/examples/coin.html +++ b/cmd/mist/assets/examples/coin.html @@ -93,18 +93,18 @@ function transact() { var to = document.querySelector("#address").value; if( to.length == 0 ) { - to = "0x4205b06c2cfa0e30359edcab94543266cb6fa1d3"; + to = "0x4205b06c2cfa0e30359edcab94543266cb6fa1d3"; } else { to = "0x"+to; } - - var value = parseInt( document.querySelector("#amount").value ); - - contract.transact({gas: "10000", gasprice: eth.gasPrice}).send( to, value ); - } - - reflesh(); - - + + var value = parseInt( document.querySelector("#amount").value ); + + contract.transact({gas: "10000", gasprice: eth.gasPrice}).send( to, value ); + } + + reflesh(); + + diff --git a/cmd/mist/assets/html/home.html b/cmd/mist/assets/html/home.html index 7116f5dde..3b27917fd 100644 --- a/cmd/mist/assets/html/home.html +++ b/cmd/mist/assets/html/home.html @@ -1,75 +1,75 @@ - -Ethereum - - - - - - -

Info

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Block number
Peer count
Accounts
Gas price
Mining
Listening
Coinbase
- - - - + + Ethereum + + + + + + +

Info

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Block number
Peer count
Accounts
Gas price
Mining
Listening
Coinbase
+ + + + -- cgit v1.2.3 From 8e8ec8f5f8974aafeac5e4a9ead76878fe22cefd Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 5 Feb 2015 03:15:05 +0100 Subject: cmd/peerserver: is gone Will be back soon. Maybe. --- cmd/peerserver/main.go | 58 -------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 cmd/peerserver/main.go (limited to 'cmd') diff --git a/cmd/peerserver/main.go b/cmd/peerserver/main.go deleted file mode 100644 index 341c4dbb9..000000000 --- a/cmd/peerserver/main.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of go-ethereum - - go-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - go-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with go-ethereum. If not, see . -*/ -package main - -import ( - "crypto/elliptic" - "flag" - "log" - "os" - - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/p2p" -) - -var ( - natType = flag.String("nat", "", "NAT traversal implementation") - pmpGateway = flag.String("gateway", "", "gateway address for NAT-PMP") - listenAddr = flag.String("addr", ":30301", "listen address") -) - -func main() { - flag.Parse() - nat, err := p2p.ParseNAT(*natType, *pmpGateway) - if err != nil { - log.Fatal("invalid nat:", err) - } - - logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.InfoLevel)) - key, _ := crypto.GenerateKey() - marshaled := elliptic.Marshal(crypto.S256(), key.PublicKey.X, key.PublicKey.Y) - - srv := p2p.Server{ - MaxPeers: 100, - Identity: p2p.NewSimpleClientIdentity("Ethereum(G)", "0.1", "Peer Server Two", marshaled), - ListenAddr: *listenAddr, - NAT: nat, - NoDial: true, - } - if err := srv.Start(); err != nil { - log.Fatal("could not start server:", err) - } - select {} -} -- cgit v1.2.3 From 56f777b2fc77275bc636562b66a08b19afe2ec56 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 5 Feb 2015 03:16:16 +0100 Subject: cmd/ethereum, cmd/mist, core, eth, javascript, xeth: fixes for new p2p API --- cmd/ethereum/main.go | 5 ++--- cmd/mist/assets/qml/main.qml | 14 +++++++++++++- cmd/mist/assets/qml/views/info.qml | 12 ------------ cmd/mist/bindings.go | 9 --------- cmd/mist/gui.go | 25 +++++++++++-------------- cmd/mist/main.go | 6 ++---- cmd/mist/ui_lib.go | 10 ++++++++-- cmd/utils/cmd.go | 6 ++---- 8 files changed, 38 insertions(+), 49 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 4b16fb79f..faac0bc5d 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/state" ) @@ -61,13 +62,11 @@ func main() { utils.InitConfig(VmType, ConfigFile, Datadir, "ETH") ethereum, err := eth.New(ð.Config{ - Name: ClientIdentifier, - Version: Version, + Name: p2p.MakeName(ClientIdentifier, Version), KeyStore: KeyStore, DataDir: Datadir, LogFile: LogFile, LogLevel: LogLevel, - Identifier: Identifier, MaxPeers: MaxPeer, Port: OutboundPort, NATType: PMPGateway, diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index 357e40846..b1d3f2d19 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -844,6 +844,7 @@ ApplicationWindow { minimumHeight: 50 title: "Connect to peer" + ComboBox { id: addrField anchors.verticalCenter: parent.verticalCenter @@ -872,6 +873,17 @@ ApplicationWindow { } } + ComboBox { + id: nodeidField + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.right: addPeerButton.left + anchors.leftMargin: 10 + anchors.rightMargin: 10 + + editable: true + } + Button { id: addPeerButton anchors.right: parent.right @@ -879,7 +891,7 @@ ApplicationWindow { anchors.rightMargin: 10 text: "Add" onClicked: { - eth.connectToPeer(addrField.currentText) + eth.connectToPeer(addrField.currentText, nodeidField.currentText) addPeerWin.visible = false } } diff --git a/cmd/mist/assets/qml/views/info.qml b/cmd/mist/assets/qml/views/info.qml index 14ee0bce1..b2d2f521c 100644 --- a/cmd/mist/assets/qml/views/info.qml +++ b/cmd/mist/assets/qml/views/info.qml @@ -32,18 +32,6 @@ Rectangle { width: 500 } - Label { - text: "Client ID" - } - TextField { - text: gui.getCustomIdentifier() - width: 500 - placeholderText: "Anonymous" - onTextChanged: { - gui.setCustomIdentifier(text) - } - } - TextArea { objectName: "statsPane" width: parent.width diff --git a/cmd/mist/bindings.go b/cmd/mist/bindings.go index 706c789b1..9623538a3 100644 --- a/cmd/mist/bindings.go +++ b/cmd/mist/bindings.go @@ -64,15 +64,6 @@ func (gui *Gui) Transact(recipient, value, gas, gasPrice, d string) (string, err return gui.xeth.Transact(recipient, value, gas, gasPrice, data) } -func (gui *Gui) SetCustomIdentifier(customIdentifier string) { - gui.clientIdentity.SetCustomIdentifier(customIdentifier) - gui.config.Save("id", customIdentifier) -} - -func (gui *Gui) GetCustomIdentifier() string { - return gui.clientIdentity.GetCustomIdentifier() -} - // functions that allow Gui to implement interface guilogger.LogSystem func (gui *Gui) SetLogLevel(level logger.LogLevel) { gui.logLevel = level diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index edc799abc..dee99859c 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -41,7 +41,6 @@ import ( "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/miner" - "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/ui/qt/qwhisper" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/qml" @@ -77,9 +76,8 @@ type Gui struct { xeth *xeth.XEth - Session string - clientIdentity *p2p.SimpleClientIdentity - config *ethutil.ConfigManager + Session string + config *ethutil.ConfigManager plugins map[string]plugin @@ -87,7 +85,7 @@ type Gui struct { } // Create GUI, but doesn't start it -func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIdentity *p2p.SimpleClientIdentity, session string, logLevel int) *Gui { +func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, session string, logLevel int) *Gui { db, err := ethdb.NewLDBDatabase("tx_database") if err != nil { panic(err) @@ -95,15 +93,14 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIden xeth := xeth.New(ethereum) gui := &Gui{eth: ethereum, - txDb: db, - xeth: xeth, - logLevel: logger.LogLevel(logLevel), - Session: session, - open: false, - clientIdentity: clientIdentity, - config: config, - plugins: make(map[string]plugin), - serviceEvents: make(chan ServEv, 1), + txDb: db, + xeth: xeth, + logLevel: logger.LogLevel(logLevel), + Session: session, + open: false, + config: config, + plugins: make(map[string]plugin), + serviceEvents: make(chan ServEv, 1), } data, _ := ethutil.ReadAllFile(path.Join(ethutil.Config.ExecPath, "plugins.json")) json.Unmarshal([]byte(data), &gui.plugins) diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 66872a241..17ab9467a 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -52,13 +52,11 @@ func run() error { config := utils.InitConfig(VmType, ConfigFile, Datadir, "ETH") ethereum, err := eth.New(ð.Config{ - Name: ClientIdentifier, - Version: Version, + Name: p2p.MakeName(ClientIdentifier, Version), KeyStore: KeyStore, DataDir: Datadir, LogFile: LogFile, LogLevel: LogLevel, - Identifier: Identifier, MaxPeers: MaxPeer, Port: OutboundPort, NATType: PMPGateway, @@ -79,7 +77,7 @@ func run() error { utils.StartWebSockets(ethereum, WsPort) } - gui := NewWindow(ethereum, config, ethereum.ClientIdentity().(*p2p.SimpleClientIdentity), KeyRing, LogLevel) + gui := NewWindow(ethereum, config, KeyRing, LogLevel) utils.RegisterInterrupt(func(os.Signal) { gui.Stop() diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go index 7c5802076..2e557dba9 100644 --- a/cmd/mist/ui_lib.go +++ b/cmd/mist/ui_lib.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/event/filter" "github.com/ethereum/go-ethereum/javascript" "github.com/ethereum/go-ethereum/miner" + "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/qml" ) @@ -142,8 +143,13 @@ func (ui *UiLib) Connect(button qml.Object) { } } -func (ui *UiLib) ConnectToPeer(addr string) { - if err := ui.eth.SuggestPeer(addr); err != nil { +func (ui *UiLib) ConnectToPeer(addr string, hexid string) { + id, err := discover.HexID(hexid) + if err != nil { + guilogger.Errorf("bad node ID: %v", err) + return + } + if err := ui.eth.SuggestPeer(addr, id); err != nil { guilogger.Infoln(err) } } diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 70df289c3..2f48bced5 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -122,12 +122,10 @@ func exit(err error) { } func StartEthereum(ethereum *eth.Ethereum, SeedNode string) { - clilogger.Infof("Starting %s", ethereum.ClientIdentity()) - err := ethereum.Start(SeedNode) - if err != nil { + clilogger.Infoln("Starting ", ethereum.Name()) + if err := ethereum.Start(SeedNode); err != nil { exit(err) } - RegisterInterrupt(func(sig os.Signal) { ethereum.Stop() logger.Flush() -- cgit v1.2.3 From 2cf4fed11b01bb99e08b838f7df2b9396f42f758 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 7 Feb 2015 00:15:04 +0100 Subject: cmd/mist, eth, javascript, p2p: use Node URLs for peer suggestions --- cmd/mist/assets/qml/main.qml | 44 +++++++++----------------------------------- cmd/mist/ui_lib.go | 12 +++--------- 2 files changed, 12 insertions(+), 44 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index b1d3f2d19..45d56e795 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -205,7 +205,7 @@ ApplicationWindow { Menu { title: "Network" MenuItem { - text: "Add Peer" + text: "Connect to Node" shortcut: "Ctrl+p" onTriggered: { addPeerWin.visible = true @@ -838,60 +838,34 @@ ApplicationWindow { Window { id: addPeerWin visible: false - minimumWidth: 300 - maximumWidth: 300 + minimumWidth: 400 + maximumWidth: 400 maximumHeight: 50 minimumHeight: 50 - title: "Connect to peer" + title: "Connect to Node" - - ComboBox { + TextField { id: addrField + placeholderText: "enode://::" anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.right: addPeerButton.left anchors.leftMargin: 10 anchors.rightMargin: 10 onAccepted: { - eth.connectToPeer(addrField.currentText) + eth.connectToPeer(addrField.text) addPeerWin.visible = false } - - editable: true - model: ListModel { id: pastPeers } - - Component.onCompleted: { - pastPeers.insert(0, {text: "poc-8.ethdev.com:30303"}) - /* - var ips = eth.pastPeers() - for(var i = 0; i < ips.length; i++) { - pastPeers.append({text: ips.get(i)}) - } - - pastPeers.insert(0, {text: "poc-7.ethdev.com:30303"}) - */ - } } - ComboBox { - id: nodeidField - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.right: addPeerButton.left - anchors.leftMargin: 10 - anchors.rightMargin: 10 - - editable: true - } - Button { id: addPeerButton anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter anchors.rightMargin: 10 - text: "Add" + text: "Connect" onClicked: { - eth.connectToPeer(addrField.currentText, nodeidField.currentText) + eth.connectToPeer(addrField.text) addPeerWin.visible = false } } diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go index 2e557dba9..dbebd8a6f 100644 --- a/cmd/mist/ui_lib.go +++ b/cmd/mist/ui_lib.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/go-ethereum/event/filter" "github.com/ethereum/go-ethereum/javascript" "github.com/ethereum/go-ethereum/miner" - "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/qml" ) @@ -143,14 +142,9 @@ func (ui *UiLib) Connect(button qml.Object) { } } -func (ui *UiLib) ConnectToPeer(addr string, hexid string) { - id, err := discover.HexID(hexid) - if err != nil { - guilogger.Errorf("bad node ID: %v", err) - return - } - if err := ui.eth.SuggestPeer(addr, id); err != nil { - guilogger.Infoln(err) +func (ui *UiLib) ConnectToPeer(nodeURL string) { + if err := ui.eth.SuggestPeer(nodeURL); err != nil { + guilogger.Infoln("SuggestPeer error: " + err.Error()) } } -- cgit v1.2.3 From 028775a0863946c1e9ad51fe7b22faa5c59b2605 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 7 Feb 2015 00:38:36 +0100 Subject: cmd/ethereum, cmd/mist: add flag for discovery bootstrap nodes --- cmd/ethereum/flags.go | 4 ++-- cmd/ethereum/main.go | 3 ++- cmd/mist/flags.go | 4 ++-- cmd/mist/main.go | 5 +++-- cmd/mist/ui_lib.go | 2 +- cmd/utils/cmd.go | 4 ++-- 6 files changed, 12 insertions(+), 10 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index af57c6a67..87fdd2838 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -49,7 +49,7 @@ var ( AddPeer string MaxPeer int GenAddr bool - SeedNode string + BootNodes string SecretFile string ExportDir string NonInteractive bool @@ -101,7 +101,7 @@ func Init() { flag.BoolVar(&StartRpc, "rpc", false, "start rpc server") flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") - flag.StringVar(&SeedNode, "seednode", "poc-8.ethdev.com:30303", "ip:port of seed node to connect to. Set to blank for skip") + flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.BoolVar(&SHH, "shh", true, "whisper protocol (on)") flag.BoolVar(&Dial, "dial", true, "dial out connections (on)") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index faac0bc5d..14e67fe4a 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -74,6 +74,7 @@ func main() { KeyRing: KeyRing, Shh: SHH, Dial: Dial, + BootNodes: BootNodes, }) if err != nil { @@ -133,7 +134,7 @@ func main() { utils.StartWebSockets(ethereum, WsPort) } - utils.StartEthereum(ethereum, SeedNode) + utils.StartEthereum(ethereum) if StartJsConsole { InitJsConsole(ethereum) diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index f042b39b0..3a7d2ac54 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -51,7 +51,7 @@ var ( AddPeer string MaxPeer int GenAddr bool - SeedNode string + BootNodes string SecretFile string ExportDir string NonInteractive bool @@ -116,7 +116,7 @@ func Init() { flag.BoolVar(&StartRpc, "rpc", true, "start rpc server") flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") - flag.StringVar(&SeedNode, "seednode", "poc-8.ethdev.com:30303", "ip:port of seed node to connect to. Set to blank for skip") + flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.StringVar(&NatType, "nat", "", "NAT support (UPNP|PMP) (none)") flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 17ab9467a..5bae33088 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -59,8 +59,9 @@ func run() error { LogLevel: LogLevel, MaxPeers: MaxPeer, Port: OutboundPort, - NATType: PMPGateway, + NATType: NatType, PMPGateway: PMPGateway, + BootNodes: BootNodes, KeyRing: KeyRing, Dial: true, }) @@ -82,7 +83,7 @@ func run() error { utils.RegisterInterrupt(func(os.Signal) { gui.Stop() }) - go utils.StartEthereum(ethereum, SeedNode) + go utils.StartEthereum(ethereum) fmt.Println("ETH stack took", time.Since(tstart)) diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go index dbebd8a6f..ba3ac3b61 100644 --- a/cmd/mist/ui_lib.go +++ b/cmd/mist/ui_lib.go @@ -136,7 +136,7 @@ func (ui *UiLib) Muted(content string) { func (ui *UiLib) Connect(button qml.Object) { if !ui.connected { - ui.eth.Start(SeedNode) + ui.eth.Start() ui.connected = true button.Set("enabled", false) } diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 2f48bced5..ecb847fc3 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -121,9 +121,9 @@ func exit(err error) { os.Exit(status) } -func StartEthereum(ethereum *eth.Ethereum, SeedNode string) { +func StartEthereum(ethereum *eth.Ethereum) { clilogger.Infoln("Starting ", ethereum.Name()) - if err := ethereum.Start(SeedNode); err != nil { + if err := ethereum.Start(); err != nil { exit(err) } RegisterInterrupt(func(sig os.Signal) { -- cgit v1.2.3 From a3cd2187194b79cd8b14c4ec4f1abca91a0147e0 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 10 Feb 2015 12:30:09 +0100 Subject: cmd/mist, cmd/ethereum: add CLI arguments for node key --- cmd/ethereum/flags.go | 39 ++++++++++++++++++++++++++++++++------- cmd/ethereum/main.go | 1 + cmd/mist/flags.go | 34 ++++++++++++++++++++++++++++------ cmd/mist/main.go | 1 + 4 files changed, 62 insertions(+), 13 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 87fdd2838..594acdf7f 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -21,6 +21,7 @@ package main import ( + "crypto/ecdsa" "flag" "fmt" "log" @@ -28,6 +29,7 @@ import ( "os/user" "path" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/vm" ) @@ -50,6 +52,7 @@ var ( MaxPeer int GenAddr bool BootNodes string + NodeKey *ecdsa.PrivateKey SecretFile string ExportDir string NonInteractive bool @@ -83,6 +86,7 @@ func defaultDataDir() string { var defaultConfigFile = path.Join(defaultDataDir(), "conf.ini") func Init() { + // TODO: move common flag processing to cmd/util flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s [options] [filename]:\noptions precedence: default < config file < environment variables < command line\n", os.Args[0]) flag.PrintDefaults() @@ -92,18 +96,12 @@ func Init() { flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") - flag.StringVar(&OutboundPort, "port", "30303", "listening port") - flag.StringVar(&NatType, "nat", "", "NAT support (UPNP|PMP) (none)") - flag.StringVar(&PMPGateway, "pmp", "", "Gateway IP for PMP") - flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") + flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", false, "start rpc server") flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") - flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") - flag.BoolVar(&SHH, "shh", true, "whisper protocol (on)") - flag.BoolVar(&Dial, "dial", true, "dial out connections (on)") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given") @@ -125,8 +123,35 @@ func Init() { flag.BoolVar(&StartJsConsole, "js", false, "launches javascript console") flag.BoolVar(&PrintVersion, "version", false, "prints version number") + // Network stuff + var ( + nodeKeyFile = flag.String("nodekey", "", "network private key file") + nodeKeyHex = flag.String("nodekeyhex", "", "network private key (for testing)") + ) + flag.BoolVar(&Dial, "dial", true, "dial out connections (default on)") + flag.BoolVar(&SHH, "shh", true, "run whisper protocol (default on)") + flag.StringVar(&OutboundPort, "port", "30303", "listening port") + flag.StringVar(&NatType, "nat", "", "NAT support (UPNP|PMP) (none)") + flag.StringVar(&PMPGateway, "pmp", "", "Gateway IP for NAT-PMP") + flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") + flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") + flag.Parse() + var err error + switch { + case *nodeKeyFile != "" && *nodeKeyHex != "": + log.Fatal("Options -nodekey and -nodekeyhex are mutually exclusive") + case *nodeKeyFile != "": + if NodeKey, err = crypto.LoadECDSA(*nodeKeyFile); err != nil { + log.Fatalf("-nodekey: %v", err) + } + case *nodeKeyHex != "": + if NodeKey, err = crypto.HexToECDSA(*nodeKeyHex); err != nil { + log.Fatalf("-nodekeyhex: %v", err) + } + } + if VmType >= int(vm.MaxVmTy) { log.Fatal("Invalid VM type ", VmType) } diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 14e67fe4a..3f616c094 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -75,6 +75,7 @@ func main() { Shh: SHH, Dial: Dial, BootNodes: BootNodes, + NodeKey: NodeKey, }) if err != nil { diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index 3a7d2ac54..dd72b5043 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -21,6 +21,7 @@ package main import ( + "crypto/ecdsa" "flag" "fmt" "log" @@ -31,6 +32,7 @@ import ( "runtime" "bitbucket.org/kardianos/osext" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/vm" ) @@ -44,7 +46,6 @@ var ( StartWebSockets bool RpcPort int WsPort int - UseUPnP bool NatType string OutboundPort string ShowGenesis bool @@ -52,6 +53,7 @@ var ( MaxPeer int GenAddr bool BootNodes string + NodeKey *ecdsa.PrivateKey SecretFile string ExportDir string NonInteractive bool @@ -99,6 +101,7 @@ func defaultDataDir() string { var defaultConfigFile = path.Join(defaultDataDir(), "conf.ini") func Init() { + // TODO: move common flag processing to cmd/utils flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s [options] [filename]:\noptions precedence: default < config file < environment variables < command line\n", os.Args[0]) flag.PrintDefaults() @@ -108,30 +111,49 @@ func Init() { flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") - flag.StringVar(&OutboundPort, "port", "30303", "listening port") - flag.BoolVar(&UseUPnP, "upnp", true, "enable UPnP support") - flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", true, "start rpc server") flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") - flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.StringVar(&NatType, "nat", "", "NAT support (UPNP|PMP) (none)") flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given") flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)") flag.StringVar(&Datadir, "datadir", defaultDataDir(), "specifies the datadir to use") - flag.StringVar(&PMPGateway, "pmp", "", "Gateway IP for PMP") flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") flag.StringVar(&AssetPath, "asset_path", defaultAssetPath(), "absolute path to GUI assets directory") + // Network stuff + var ( + nodeKeyFile = flag.String("nodekey", "", "network private key file") + nodeKeyHex = flag.String("nodekeyhex", "", "network private key (for testing)") + ) + flag.StringVar(&OutboundPort, "port", "30303", "listening port") + flag.StringVar(&PMPGateway, "pmp", "", "Gateway IP for NAT-PMP") + flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") + flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") + flag.Parse() + var err error + switch { + case *nodeKeyFile != "" && *nodeKeyHex != "": + log.Fatal("Options -nodekey and -nodekeyhex are mutually exclusive") + case *nodeKeyFile != "": + if NodeKey, err = crypto.LoadECDSA(*nodeKeyFile); err != nil { + log.Fatalf("-nodekey: %v", err) + } + case *nodeKeyHex != "": + if NodeKey, err = crypto.HexToECDSA(*nodeKeyHex); err != nil { + log.Fatalf("-nodekeyhex: %v", err) + } + } + if VmType >= int(vm.MaxVmTy) { log.Fatal("Invalid VM type ", VmType) } diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 5bae33088..4d6bac9b7 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -62,6 +62,7 @@ func run() error { NATType: NatType, PMPGateway: PMPGateway, BootNodes: BootNodes, + NodeKey: NodeKey, KeyRing: KeyRing, Dial: true, }) -- cgit v1.2.3 From da2fae0e437f9467a943acfe0571a8a24e8e76fd Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 9 Feb 2015 16:20:34 +0100 Subject: Basic structure miner --- cmd/mist/gui.go | 2 +- cmd/mist/ui_lib.go | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index edc799abc..fdd823171 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -455,7 +455,7 @@ func (gui *Gui) update() { case <-generalUpdateTicker.C: statusText := "#" + gui.eth.ChainManager().CurrentBlock().Number().String() lastBlockLabel.Set("text", statusText) - miningLabel.Set("text", "Mining @ "+strconv.FormatInt(gui.uiLib.miner.GetPow().GetHashrate(), 10)+"Khash") + miningLabel.Set("text", "Mining @ "+strconv.FormatInt(gui.uiLib.miner.HashRate(), 10)+"/Khash") /* blockLength := gui.eth.BlockPool().BlocksProcessed diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go index 7c5802076..3b9e35c1b 100644 --- a/cmd/mist/ui_lib.go +++ b/cmd/mist/ui_lib.go @@ -209,17 +209,20 @@ func (self *UiLib) Call(params map[string]interface{}) (string, error) { } func (self *UiLib) AddLocalTransaction(to, data, gas, gasPrice, value string) int { - return self.miner.AddLocalTx(&miner.LocalTx{ - To: ethutil.Hex2Bytes(to), - Data: ethutil.Hex2Bytes(data), - Gas: gas, - GasPrice: gasPrice, - Value: value, - }) - 1 + return 0 + /* + return self.miner.AddLocalTx(&miner.LocalTx{ + To: ethutil.Hex2Bytes(to), + Data: ethutil.Hex2Bytes(data), + Gas: gas, + GasPrice: gasPrice, + Value: value, + }) - 1 + */ } func (self *UiLib) RemoveLocalTransaction(id int) { - self.miner.RemoveLocalTx(id) + //self.miner.RemoveLocalTx(id) } func (self *UiLib) SetGasPrice(price string) { -- cgit v1.2.3 From 4242b054628b46ea3470e156992c8e41e01c0739 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 10 Feb 2015 14:26:54 +0100 Subject: cmd/bootnode: new command (replaces cmd/peerserver) --- cmd/bootnode/main.go | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 cmd/bootnode/main.go (limited to 'cmd') diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go new file mode 100644 index 000000000..fd96a7b48 --- /dev/null +++ b/cmd/bootnode/main.go @@ -0,0 +1,86 @@ +/* + This file is part of go-ethereum + + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . +*/ + +// Command bootnode runs a bootstrap node for the Discovery Protocol. +package main + +import ( + "crypto/ecdsa" + "encoding/hex" + "flag" + "fmt" + "io/ioutil" + "log" + "os" + + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/p2p/discover" +) + +func main() { + var ( + listenAddr = flag.String("addr", ":30301", "listen address") + genKey = flag.String("genkey", "", "generate a node key and quit") + nodeKeyFile = flag.String("nodekey", "", "private key filename") + nodeKeyHex = flag.String("nodekeyhex", "", "private key as hex (for testing)") + nodeKey *ecdsa.PrivateKey + err error + ) + flag.Parse() + logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.DebugLevel)) + + if *genKey != "" { + writeKey(*genKey) + os.Exit(0) + } + + switch { + case *nodeKeyFile == "" && *nodeKeyHex == "": + log.Fatal("Use -nodekey or -nodekeyhex to specify a private key") + case *nodeKeyFile != "" && *nodeKeyHex != "": + log.Fatal("Options -nodekey and -nodekeyhex are mutually exclusive") + case *nodeKeyFile != "": + if nodeKey, err = crypto.LoadECDSA(*nodeKeyFile); err != nil { + log.Fatalf("-nodekey: %v", err) + } + case *nodeKeyHex != "": + if nodeKey, err = crypto.HexToECDSA(*nodeKeyHex); err != nil { + log.Fatalf("-nodekeyhex: %v", err) + } + } + + if _, err := discover.ListenUDP(nodeKey, *listenAddr); err != nil { + log.Fatal(err) + } + select {} +} + +func writeKey(target string) { + key, err := crypto.GenerateKey() + if err != nil { + log.Fatal("could not generate key: %v", err) + } + b := crypto.FromECDSA(key) + if target == "-" { + fmt.Println(hex.EncodeToString(b)) + } else { + if err := ioutil.WriteFile(target, b, 0600); err != nil { + log.Fatal("write error: ", err) + } + } +} -- cgit v1.2.3 From df49c609a0fd055a4f0dac89db6863ad5532228f Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 11 Feb 2015 13:26:44 +0100 Subject: updated coin --- cmd/mist/assets/examples/coin.html | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/examples/coin.html b/cmd/mist/assets/examples/coin.html index 71b359834..546c6f13f 100644 --- a/cmd/mist/assets/examples/coin.html +++ b/cmd/mist/assets/examples/coin.html @@ -7,7 +7,7 @@ -

JevCoin

+

JevCoin

Balance @@ -58,29 +58,25 @@ }], "outputs": [] }, { - "name":"changed", + "name":"received", "type":"event", "inputs": [ - {"name":"to","type":"address","indexed":true}, {"name":"from","type":"address","indexed":true}, + {"name":"amount","type":"uint256","indexed":true}, ], }]; var address = localStorage.getItem("address"); // deploy if not exist if (address == null) { - var code = "0x60056013565b610132806100356000396000f35b620f4240600033600160a060020a0316600052602052604060002081905550560060e060020a6000350480637bb98a681461002b578063d0679d3414610039578063e3d670d71461004d57005b61003361012d565b60006000f35b610047600435602435610062565b60006000f35b61005860043561010b565b8060005260206000f35b80600033600160a060020a0316600052602052604060002054106100855761008a565b610107565b80600033600160a060020a0316600052602052604060002090815403908190555080600083600160a060020a0316600052602052604060002090815401908190555081600160a060020a031633600160a060020a03167f1863989b4bb7c5c3941722099764574df7a459f9f9c6b6cdca35ddc9731792b860006000a35b5050565b6000600082600160a060020a03166000526020526040600020549050919050565b5b60008156"; - address = web3.eth.transact({ - data: code, - gasPrice: "1000000000000000", - gas: "10000", - }); + var code = "0x60056013565b61012b806100346000396000f35b6103e8600033600160a060020a0316600052602052604060002081905550560060e060020a6000350480637bb98a681461002b578063d0679d3414610039578063e3d670d71461004d57005b610033610126565b60006000f35b610047600435602435610062565b60006000f35b610058600435610104565b8060005260206000f35b80600033600160a060020a0316600052602052604060002054101561008657610100565b80600033600160a060020a0316600052602052604060002090815403908190555080600083600160a060020a0316600052602052604060002090815401908190555033600160a060020a0316600052806020527ff11e547d796cc64acdf758e7cee90439494fd886a19159454aa61e473fdbafef60406000a15b5050565b6000600082600160a060020a03166000526020526040600020549050919050565b5b60008156"; + address = web3.eth.transact({data: code}); localStorage.setItem("address", address); } - document.querySelector("#address").innerHTML = address.toUpperCase(); + document.querySelector("#contract_addr").innerHTML = address.toUpperCase(); var contract = web3.eth.contract(address, desc); - contract.changed({from: eth.accounts[0]}).changed(function() { + contract.received({from: eth.coinbase}).changed(function() { refresh(); }); eth.watch('chain').changed(function() { @@ -102,7 +98,6 @@ function transact() { var to = document.querySelector("#address").value; - if( to.length == 0 ) { to = "0x4205b06c2cfa0e30359edcab94543266cb6fa1d3"; } else { -- cgit v1.2.3 From 3f6baa45a7fb1ae5fd7966d2763a2a776a65eb96 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 11 Feb 2015 23:46:45 +0100 Subject: Documented methods & removed old manifest --- cmd/mist/assets/examples/coin.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 cmd/mist/assets/examples/coin.js (limited to 'cmd') diff --git a/cmd/mist/assets/examples/coin.js b/cmd/mist/assets/examples/coin.js new file mode 100644 index 000000000..ada9d196c --- /dev/null +++ b/cmd/mist/assets/examples/coin.js @@ -0,0 +1 @@ +var contract = web3.eth.contractFromAbi([{"constant":false,"inputs":[{"name":"_h","type":"hash256"}],"name":"confirm","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"execute","outputs":[{"name":"_r","type":"hash256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"}],"name":"kill","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"}],"name":"changeOwner","outputs":[],"type":"function"},{"inputs":[{"indexed":false,"name":"value","type":"uint256"}],"name":"CashIn","type":"event"},{"inputs":[{"indexed":true,"name":"out","type":"string32"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"to","type":"address"}],"name":"SingleTransact","type":"event"},{"inputs":[{"indexed":true,"name":"out","type":"string32"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"operation","type":"hash256"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"to","type":"address"}],"name":"MultiTransact","type":"event"}]); -- cgit v1.2.3 From 31fdc645ed9c6bfa63deb8a688888b6cacfd821e Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 12 Feb 2015 15:03:53 +0100 Subject: cmd + t switches to new dapp window --- cmd/mist/assets/qml/main.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index d03ef43d9..2b56b7236 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -17,6 +17,7 @@ ApplicationWindow { // Use this to make the window frameless. But then you'll need to do move and resize by hand property var ethx : Eth.ethx + property var catalog; width: 1200 height: 820 @@ -39,7 +40,7 @@ ApplicationWindow { // Takes care of loading all default plugins Component.onCompleted: { - var catalog = addPlugin("./views/catalog.qml", {noAdd: true, close: false, section: "begin"}); + catalog = addPlugin("./views/catalog.qml", {noAdd: true, close: false, section: "begin"}); var wallet = addPlugin("./views/wallet.qml", {noAdd: true, close: false, section: "ethereum", active: true}); addPlugin("./views/miner.qml", {noAdd: true, close: false, section: "ethereum", active: true}); @@ -169,7 +170,7 @@ ApplicationWindow { text: "New tab" shortcut: "Ctrl+t" onTriggered: { - newBrowserTab("http://etherian.io"); + activeView(catalog.view, catalog.menuItem); } } -- cgit v1.2.3 From 38faf2c51a1e4a86cda5dfa1b4f7fdae4fd7f58d Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 12 Feb 2015 17:06:15 +0100 Subject: removed messages --- cmd/mist/ext_app.go | 26 -------------------------- cmd/mist/html_container.go | 14 -------------- cmd/mist/qml_container.go | 6 ------ 3 files changed, 46 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/ext_app.go b/cmd/mist/ext_app.go index 20ec52e60..4831884e5 100644 --- a/cmd/mist/ext_app.go +++ b/cmd/mist/ext_app.go @@ -24,7 +24,6 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/ui/qt" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/qml" @@ -39,7 +38,6 @@ type AppContainer interface { NewBlock(*types.Block) NewWatcher(chan bool) - Messages(state.Messages, string) Post(string, int) } @@ -79,10 +77,6 @@ func (app *ExtApplication) run() { return } - // Subscribe to events - mux := app.lib.eth.EventMux() - app.events = mux.Subscribe(core.NewBlockEvent{}, state.Messages(nil)) - // Call the main loop go app.mainLoop() @@ -126,23 +120,3 @@ func (app *ExtApplication) mainLoop() { func (self *ExtApplication) Watch(filterOptions map[string]interface{}, identifier string) { self.filters[identifier] = qt.NewFilterFromMap(filterOptions, self.eth) } - -func (self *ExtApplication) GetMessages(object map[string]interface{}) string { - /* TODO remove me - filter := qt.NewFilterFromMap(object, self.eth) - - messages := filter.Find() - var msgs []javascript.JSMessage - for _, m := range messages { - msgs = append(msgs, javascript.NewJSMessage(m)) - } - - b, err := json.Marshal(msgs) - if err != nil { - return "{\"error\":" + err.Error() + "}" - } - - return string(b) - */ - return "" -} diff --git a/cmd/mist/html_container.go b/cmd/mist/html_container.go index 0909a6abd..e4ea57b9b 100644 --- a/cmd/mist/html_container.go +++ b/cmd/mist/html_container.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethutil" - "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" "github.com/howeyc/fsnotify" "github.com/obscuren/qml" @@ -144,19 +143,6 @@ func (app *HtmlApplication) NewBlock(block *types.Block) { app.webView.Call("onNewBlockCb", b) } -func (self *HtmlApplication) Messages(messages state.Messages, id string) { - /* TODO remove me - var msgs []javascript.JSMessage - for _, m := range messages { - msgs = append(msgs, javascript.NewJSMessage(m)) - } - - b, _ := json.Marshal(msgs) - - self.webView.Call("onWatchedCb", string(b), id) - */ -} - func (app *HtmlApplication) Destroy() { app.engine.Destroy() } diff --git a/cmd/mist/qml_container.go b/cmd/mist/qml_container.go index 9d76d8fe4..16a055bc0 100644 --- a/cmd/mist/qml_container.go +++ b/cmd/mist/qml_container.go @@ -22,12 +22,10 @@ package main import ( - "fmt" "runtime" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethutil" - "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/qml" ) @@ -74,10 +72,6 @@ func (app *QmlApplication) NewBlock(block *types.Block) { app.win.Call("onNewBlockCb", pblock) } -func (self *QmlApplication) Messages(msgs state.Messages, id string) { - fmt.Println("IMPLEMENT QML APPLICATION MESSAGES METHOD") -} - // Getters func (app *QmlApplication) Engine() *qml.Engine { return app.engine -- cgit v1.2.3 From d0a2e655c9599f462bb20bd49bc69b8e1e330a21 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 11 Feb 2015 17:19:31 +0100 Subject: cmd/ethereum, cmd/mist, eth, p2p: use package p2p/nat This deletes the old NAT implementation. --- cmd/ethereum/flags.go | 11 +++++++---- cmd/ethereum/main.go | 27 +++++++++++++-------------- cmd/mist/flags.go | 10 ++++++---- cmd/mist/main.go | 25 ++++++++++++------------- 4 files changed, 38 insertions(+), 35 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 594acdf7f..99e094b47 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/vm" ) @@ -44,8 +45,6 @@ var ( StartWebSockets bool RpcPort int WsPort int - NatType string - PMPGateway string OutboundPort string ShowGenesis bool AddPeer string @@ -53,6 +52,7 @@ var ( GenAddr bool BootNodes string NodeKey *ecdsa.PrivateKey + NAT nat.Interface SecretFile string ExportDir string NonInteractive bool @@ -127,18 +127,21 @@ func Init() { var ( nodeKeyFile = flag.String("nodekey", "", "network private key file") nodeKeyHex = flag.String("nodekeyhex", "", "network private key (for testing)") + natstr = flag.String("nat", "any", "port mapping mechanism (any|none|upnp|pmp|extip:)") ) flag.BoolVar(&Dial, "dial", true, "dial out connections (default on)") flag.BoolVar(&SHH, "shh", true, "run whisper protocol (default on)") flag.StringVar(&OutboundPort, "port", "30303", "listening port") - flag.StringVar(&NatType, "nat", "", "NAT support (UPNP|PMP) (none)") - flag.StringVar(&PMPGateway, "pmp", "", "Gateway IP for NAT-PMP") + flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") flag.Parse() var err error + if NAT, err = nat.Parse(*natstr); err != nil { + log.Fatalf("-nat: %v", err) + } switch { case *nodeKeyFile != "" && *nodeKeyHex != "": log.Fatal("Options -nodekey and -nodekeyhex are mutually exclusive") diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 3f616c094..d2b3418cd 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -62,20 +62,19 @@ func main() { utils.InitConfig(VmType, ConfigFile, Datadir, "ETH") ethereum, err := eth.New(ð.Config{ - Name: p2p.MakeName(ClientIdentifier, Version), - KeyStore: KeyStore, - DataDir: Datadir, - LogFile: LogFile, - LogLevel: LogLevel, - MaxPeers: MaxPeer, - Port: OutboundPort, - NATType: PMPGateway, - PMPGateway: PMPGateway, - KeyRing: KeyRing, - Shh: SHH, - Dial: Dial, - BootNodes: BootNodes, - NodeKey: NodeKey, + Name: p2p.MakeName(ClientIdentifier, Version), + KeyStore: KeyStore, + DataDir: Datadir, + LogFile: LogFile, + LogLevel: LogLevel, + MaxPeers: MaxPeer, + Port: OutboundPort, + NAT: NAT, + KeyRing: KeyRing, + Shh: SHH, + Dial: Dial, + BootNodes: BootNodes, + NodeKey: NodeKey, }) if err != nil { diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index dd72b5043..eb280f71b 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -34,6 +34,7 @@ import ( "bitbucket.org/kardianos/osext" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/vm" ) @@ -41,12 +42,10 @@ var ( Identifier string KeyRing string KeyStore string - PMPGateway string StartRpc bool StartWebSockets bool RpcPort int WsPort int - NatType string OutboundPort string ShowGenesis bool AddPeer string @@ -54,6 +53,7 @@ var ( GenAddr bool BootNodes string NodeKey *ecdsa.PrivateKey + NAT nat.Interface SecretFile string ExportDir string NonInteractive bool @@ -117,7 +117,6 @@ func Init() { flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") - flag.StringVar(&NatType, "nat", "", "NAT support (UPNP|PMP) (none)") flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given") flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)") @@ -132,15 +131,18 @@ func Init() { var ( nodeKeyFile = flag.String("nodekey", "", "network private key file") nodeKeyHex = flag.String("nodekeyhex", "", "network private key (for testing)") + natstr = flag.String("nat", "any", "port mapping mechanism (any|none|upnp|pmp|extip:)") ) flag.StringVar(&OutboundPort, "port", "30303", "listening port") - flag.StringVar(&PMPGateway, "pmp", "", "Gateway IP for NAT-PMP") flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") flag.Parse() var err error + if NAT, err = nat.Parse(*natstr); err != nil { + log.Fatalf("-nat: %v", err) + } switch { case *nodeKeyFile != "" && *nodeKeyHex != "": log.Fatal("Options -nodekey and -nodekeyhex are mutually exclusive") diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 4d6bac9b7..52b5e4e94 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -52,19 +52,18 @@ func run() error { config := utils.InitConfig(VmType, ConfigFile, Datadir, "ETH") ethereum, err := eth.New(ð.Config{ - Name: p2p.MakeName(ClientIdentifier, Version), - KeyStore: KeyStore, - DataDir: Datadir, - LogFile: LogFile, - LogLevel: LogLevel, - MaxPeers: MaxPeer, - Port: OutboundPort, - NATType: NatType, - PMPGateway: PMPGateway, - BootNodes: BootNodes, - NodeKey: NodeKey, - KeyRing: KeyRing, - Dial: true, + Name: p2p.MakeName(ClientIdentifier, Version), + KeyStore: KeyStore, + DataDir: Datadir, + LogFile: LogFile, + LogLevel: LogLevel, + MaxPeers: MaxPeer, + Port: OutboundPort, + NAT: NAT, + BootNodes: BootNodes, + NodeKey: NodeKey, + KeyRing: KeyRing, + Dial: true, }) if err != nil { mainlogger.Fatalln(err) -- cgit v1.2.3 From 170eb3ac684231dc2ddebc34e7006e0f2b5fc0c1 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 13 Feb 2015 11:38:34 +0100 Subject: p2p/discover: map listening port using configured mechanism --- cmd/bootnode/main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go index fd96a7b48..dda9f34d4 100644 --- a/cmd/bootnode/main.go +++ b/cmd/bootnode/main.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/p2p/nat" ) func main() { @@ -38,8 +39,10 @@ func main() { genKey = flag.String("genkey", "", "generate a node key and quit") nodeKeyFile = flag.String("nodekey", "", "private key filename") nodeKeyHex = flag.String("nodekeyhex", "", "private key as hex (for testing)") - nodeKey *ecdsa.PrivateKey - err error + natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:)") + + nodeKey *ecdsa.PrivateKey + err error ) flag.Parse() logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.DebugLevel)) @@ -49,6 +52,10 @@ func main() { os.Exit(0) } + natm, err := nat.Parse(*natdesc) + if err != nil { + log.Fatalf("-nat: %v", err) + } switch { case *nodeKeyFile == "" && *nodeKeyHex == "": log.Fatal("Use -nodekey or -nodekeyhex to specify a private key") @@ -64,7 +71,7 @@ func main() { } } - if _, err := discover.ListenUDP(nodeKey, *listenAddr); err != nil { + if _, err := discover.ListenUDP(nodeKey, *listenAddr, natm); err != nil { log.Fatal(err) } select {} -- cgit v1.2.3 From bde3ff16ad98cb4ab0befc899f7f0584d21ff9a4 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 16:02:37 +0100 Subject: merge --- cmd/mist/assets/examples/coin.html | 6 + cmd/mist/assets/qml/main.qml | 869 +------------------------------------ 2 files changed, 7 insertions(+), 868 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/examples/coin.html b/cmd/mist/assets/examples/coin.html index 546c6f13f..99e0c7643 100644 --- a/cmd/mist/assets/examples/coin.html +++ b/cmd/mist/assets/examples/coin.html @@ -79,6 +79,12 @@ contract.received({from: eth.coinbase}).changed(function() { refresh(); }); + + var ev = contract.SingleTransact({}) + ev.watch(function(log) { + someElement.innerHTML += "tnaheousnthaoeu"; + }); + eth.watch('chain').changed(function() { refresh(); }); diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index 8f9a2d3cc..2b56b7236 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -11,7 +11,6 @@ import "../ext/http.js" as Http ApplicationWindow { -<<<<<<< HEAD id: root //flags: Qt.FramelessWindowHint @@ -1102,870 +1101,4 @@ ApplicationWindow { addrField.focus = true } } - } -======= - id: root - - property var ethx : Eth.ethx - - width: 1200 - height: 820 - minimumWidth: 300 - - title: "Mist" - - TextField { - id: copyElementHax - visible: false - } - - function copyToClipboard(text) { - copyElementHax.text = text - copyElementHax.selectAll() - copyElementHax.copy() - } - - // Takes care of loading all default plugins - Component.onCompleted: { - var wallet = addPlugin("./views/wallet.qml", {noAdd: true, close: false, section: "ethereum", active: true}); - addPlugin("./views/miner.qml", {noAdd: true, close: false, section: "ethereum", active: true}); - - addPlugin("./views/transaction.qml", {noAdd: true, close: false, section: "legacy"}); - addPlugin("./views/whisper.qml", {noAdd: true, close: false, section: "legacy"}); - addPlugin("./views/chain.qml", {noAdd: true, close: false, section: "legacy"}); - addPlugin("./views/pending_tx.qml", {noAdd: true, close: false, section: "legacy"}); - addPlugin("./views/info.qml", {noAdd: true, close: false, section: "legacy"}); - - mainSplit.setView(wallet.view, wallet.menuItem); - - newBrowserTab(eth.assetPath("html/home.html")); - - // Command setup - gui.sendCommand(0) - } - - function activeView(view, menuItem) { - mainSplit.setView(view, menuItem) - if (view.hideUrl) { - urlPane.visible = false; - mainView.anchors.top = rootView.top - } else { - urlPane.visible = true; - mainView.anchors.top = divider.bottom - } - } - - function addViews(view, path, options) { - var views = mainSplit.addComponent(view, options) - views.menuItem.path = path - - mainSplit.views.push(views); - - if(!options.noAdd) { - gui.addPlugin(path) - } - - return views - } - - function addPlugin(path, options) { - try { - if(typeof(path) === "string" && /^https?/.test(path)) { - console.log('load http') - Http.request(path, function(o) { - if(o.status === 200) { - var view = Qt.createQmlObject(o.responseText, mainView, path) - addViews(view, path, options) - } - }) - - return - } - - var component = Qt.createComponent(path); - if(component.status != Component.Ready) { - if(component.status == Component.Error) { - ethx.note("error: ", component.errorString()); - } - - return - } - - var view = mainView.createView(component, options) - var views = addViews(view, path, options) - - return views - } catch(e) { - console.log(e) - } - } - - function newBrowserTab(url) { - var window = addPlugin("./views/browser.qml", {noAdd: true, close: true, section: "apps", active: true}); - window.view.url = url; - window.menuItem.title = "Mist"; - activeView(window.view, window.menuItem); - } - - menuBar: MenuBar { - Menu { - title: "File" - MenuItem { - text: "Import App" - shortcut: "Ctrl+o" - onTriggered: { - generalFileDialog.show(true, importApp) - } - } - - MenuItem { - text: "Add plugin" - onTriggered: { - generalFileDialog.show(true, function(path) { - addPlugin(path, {close: true, section: "apps"}) - }) - } - } - - MenuItem { - text: "New tab" - shortcut: "Ctrl+t" - onTriggered: { - newBrowserTab("about:blank"); - } - } - - MenuSeparator {} - - MenuItem { - text: "Import key" - shortcut: "Ctrl+i" - onTriggered: { - generalFileDialog.show(true, function(path) { - gui.importKey(path) - }) - } - } - - MenuItem { - text: "Export keys" - shortcut: "Ctrl+e" - onTriggered: { - generalFileDialog.show(false, function(path) { - }) - } - } - - } - - Menu { - title: "Developer" - MenuItem { - iconSource: "../icecream.png" - text: "Debugger" - shortcut: "Ctrl+d" - onTriggered: eth.startDebugger() - } - - MenuItem { - text: "Import Tx" - onTriggered: { - txImportDialog.visible = true - } - } - - MenuItem { - text: "Run JS file" - onTriggered: { - generalFileDialog.show(true, function(path) { - eth.evalJavascriptFile(path) - }) - } - } - - MenuItem { - text: "Dump state" - onTriggered: { - generalFileDialog.show(false, function(path) { - // Empty hash for latest - gui.dumpState("", path) - }) - } - } - - MenuSeparator {} - } - - Menu { - title: "Network" - MenuItem { - text: "Connect to Node" - shortcut: "Ctrl+p" - onTriggered: { - addPeerWin.visible = true - } - } - MenuItem { - text: "Show Peers" - shortcut: "Ctrl+e" - onTriggered: { - peerWindow.visible = true - } - } - } - - Menu { - title: "Help" - MenuItem { - text: "About" - onTriggered: { - aboutWin.visible = true - } - } - } - - Menu { - title: "GLOBAL SHORTCUTS" - visible: false - MenuItem { - visible: false - shortcut: "Ctrl+l" - onTriggered: { - url.focus = true - } - } - } - } - - statusBar: StatusBar { - //height: 32 - id: statusBar - Label { - //y: 6 - id: walletValueLabel - - font.pixelSize: 10 - styleColor: "#797979" - } - - Label { - //y: 6 - objectName: "miningLabel" - visible: true - font.pixelSize: 10 - anchors.right: lastBlockLabel.left - anchors.rightMargin: 5 - } - - Label { - //y: 6 - id: lastBlockLabel - objectName: "lastBlockLabel" - visible: true - text: "" - font.pixelSize: 10 - anchors.right: peerGroup.left - anchors.rightMargin: 5 - } - - ProgressBar { - visible: false - id: downloadIndicator - value: 0 - objectName: "downloadIndicator" - y: -4 - x: statusBar.width / 2 - this.width / 2 - width: 160 - } - - Label { - visible: false - objectName: "downloadLabel" - //y: 7 - anchors.left: downloadIndicator.right - anchors.leftMargin: 5 - font.pixelSize: 10 - text: "0 / 0" - } - - - RowLayout { - id: peerGroup - //y: 7 - anchors.right: parent.right - MouseArea { - onDoubleClicked: peerWindow.visible = true - anchors.fill: parent - } - - Label { - id: peerLabel - font.pixelSize: 10 - text: "0 / 0" - } - } - } - - - property var blockModel: ListModel { - id: blockModel - } - - SplitView { - property var views: []; - - id: mainSplit - anchors.fill: parent - resizing: false - - function setView(view, menu) { - for(var i = 0; i < views.length; i++) { - views[i].view.visible = false - views[i].menuItem.setSelection(false) - } - view.visible = true - menu.setSelection(true) - } - - function addComponent(view, options) { - view.visible = false - view.anchors.fill = mainView - - var menuItem = menu.createMenuItem(view, options); - if( view.hasOwnProperty("menuItem") ) { - view.menuItem = menuItem; - } - - if( view.hasOwnProperty("onReady") ) { - view.onReady.call(view) - } - - if( options.active ) { - setView(view, menuItem) - } - - - return {view: view, menuItem: menuItem} - } - - /********************* - * Main menu. - ********************/ - Rectangle { - id: menu - Layout.minimumWidth: 210 - Layout.maximumWidth: 210 - anchors.top: parent.top - color: "#ececec" - - Component { - id: menuItemTemplate - Rectangle { - id: menuItem - property var view; - property var path; - property var closable; - - property alias title: label.text - property alias icon: icon.source - property alias secondaryTitle: secondary.text - function setSelection(on) { - sel.visible = on - } - - width: 206 - height: 28 - color: "#00000000" - - anchors { - left: parent.left - leftMargin: 4 - } - - Rectangle { - id: sel - visible: false - anchors.fill: parent - color: "#00000000" - Rectangle { - id: r - anchors.fill: parent - border.color: "#CCCCCC" - border.width: 1 - radius: 5 - color: "#FFFFFFFF" - } - Rectangle { - anchors { - top: r.top - bottom: r.bottom - right: r.right - } - width: 10 - color: "#FFFFFFFF" - - Rectangle { - anchors { - left: parent.left - right: parent.right - top: parent.top - } - height: 1 - color: "#CCCCCC" - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: 1 - color: "#CCCCCC" - } - } - } - - MouseArea { - anchors.fill: parent - onClicked: { - activeView(view, menuItem); - } - } - - Image { - id: icon - height: 20 - width: 20 - anchors { - left: parent.left - verticalCenter: parent.verticalCenter - leftMargin: 3 - } - MouseArea { - anchors.fill: parent - onClicked: { - menuItem.closeApp() - } - } - } - - Text { - id: label - anchors { - left: icon.right - verticalCenter: parent.verticalCenter - leftMargin: 3 - } - - color: "#0D0A01" - font.pixelSize: 12 - } - - Text { - id: secondary - anchors { - right: parent.right - rightMargin: 8 - verticalCenter: parent.verticalCenter - } - color: "#AEADBE" - font.pixelSize: 12 - } - - - function closeApp() { - if(!this.closable) { return; } - - if(this.view.hasOwnProperty("onDestroy")) { - this.view.onDestroy.call(this.view) - } - - this.view.destroy() - this.destroy() - for (var i = 0; i < mainSplit.views.length; i++) { - var view = mainSplit.views[i]; - if (view.menuItem === this) { - mainSplit.views.splice(i, 1); - break; - } - } - gui.removePlugin(this.path) - activeView(mainSplit.views[0].view, mainSplit.views[0].menuItem); - } - } - } - - function createMenuItem(view, options) { - if(options === undefined) { - options = {}; - } - - var section; - switch(options.section) { - case "ethereum": - section = menuDefault; - break; - case "legacy": - section = menuLegacy; - break; - default: - section = menuApps; - break; - } - - var comp = menuItemTemplate.createObject(section) - comp.view = view - comp.title = view.title - - if(view.hasOwnProperty("iconSource")) { - comp.icon = view.iconSource; - } - comp.closable = options.close; - - return comp - } - - ColumnLayout { - id: menuColumn - y: 10 - width: parent.width - anchors.left: parent.left - anchors.right: parent.right - spacing: 3 - - Text { - text: "ETHEREUM" - font.bold: true - anchors { - left: parent.left - leftMargin: 5 - } - color: "#888888" - } - - ColumnLayout { - id: menuDefault - spacing: 3 - anchors { - left: parent.left - right: parent.right - } - } - - - Text { - text: "NET" - font.bold: true - anchors { - left: parent.left - leftMargin: 5 - } - color: "#888888" - } - - ColumnLayout { - id: menuApps - spacing: 3 - anchors { - left: parent.left - right: parent.right - } - } - - Text { - text: "DEBUG" - font.bold: true - anchors { - left: parent.left - leftMargin: 5 - } - color: "#888888" - } - - ColumnLayout { - id: menuLegacy - spacing: 3 - anchors { - left: parent.left - right: parent.right - } - } - } - } - - /********************* - * Main view - ********************/ - Rectangle { - id: rootView - anchors.right: parent.right - anchors.left: menu.right - anchors.bottom: parent.bottom - anchors.top: parent.top - color: "#00000000" - - Rectangle { - id: urlPane - height: 40 - color: "#00000000" - anchors { - left: parent.left - right: parent.right - leftMargin: 5 - rightMargin: 5 - top: parent.top - topMargin: 5 - } - TextField { - id: url - objectName: "url" - placeholderText: "DApp URL" - anchors { - left: parent.left - right: parent.right - top: parent.top - topMargin: 5 - rightMargin: 5 - leftMargin: 5 - } - - Keys.onReturnPressed: { - if(/^https?/.test(this.text)) { - newBrowserTab(this.text); - } else { - addPlugin(this.text, {close: true, section: "apps"}) - } - } - } - - } - - // Border - Rectangle { - id: divider - anchors { - left: parent.left - right: parent.right - top: urlPane.bottom - } - z: -1 - height: 1 - color: "#CCCCCC" - } - - Rectangle { - id: mainView - color: "#00000000" - anchors.right: parent.right - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.top: divider.bottom - - function createView(component) { - var view = component.createObject(mainView) - - return view; - } - } - } - } - - - /****************** - * Dialogs - *****************/ - FileDialog { - id: generalFileDialog - property var callback; - onAccepted: { - var path = this.fileUrl.toString(); - callback.call(this, path); - } - - function show(selectExisting, callback) { - generalFileDialog.callback = callback; - generalFileDialog.selectExisting = selectExisting; - - this.open(); - } - } - - - /****************** - * Wallet functions - *****************/ - function importApp(path) { - var ext = path.split('.').pop() - if(ext == "html" || ext == "htm") { - eth.openHtml(path) - }else if(ext == "qml"){ - addPlugin(path, {close: true, section: "apps"}) - } - } - - - function setWalletValue(value) { - walletValueLabel.text = value - } - - function loadPlugin(name) { - console.log("Loading plugin" + name) - var view = mainView.addPlugin(name) - } - - function setPeers(text) { - peerLabel.text = text - } - - function addPeer(peer) { - // We could just append the whole peer object but it cries if you try to alter them - peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), latency: peer.latency, version: peer.version, caps: peer.caps}) - } - - function resetPeers(){ - peerModel.clear() - } - - function timeAgo(unixTs){ - var lapsed = (Date.now() - new Date(unixTs*1000)) / 1000 - return (lapsed + " seconds ago") - } - - function convertToPretty(unixTs){ - var a = new Date(unixTs*1000); - var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; - var year = a.getFullYear(); - var month = months[a.getMonth()]; - var date = a.getDate(); - var hour = a.getHours(); - var min = a.getMinutes(); - var sec = a.getSeconds(); - var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ; - return time; - } - - /********************** - * Windows - *********************/ - Window { - id: peerWindow - //flags: Qt.CustomizeWindowHint | Qt.Tool | Qt.WindowCloseButtonHint - height: 200 - width: 700 - Rectangle { - anchors.fill: parent - property var peerModel: ListModel { - id: peerModel - } - TableView { - anchors.fill: parent - id: peerTable - model: peerModel - TableViewColumn{width: 200; role: "ip" ; title: "IP" } - TableViewColumn{width: 260; role: "version" ; title: "Version" } - TableViewColumn{width: 180; role: "caps" ; title: "Capabilities" } - } - } - } - - Window { - id: aboutWin - visible: false - title: "About" - minimumWidth: 350 - maximumWidth: 350 - maximumHeight: 280 - minimumHeight: 280 - - Image { - id: aboutIcon - height: 150 - width: 150 - fillMode: Image.PreserveAspectFit - smooth: true - source: "../facet.png" - x: 10 - y: 30 - } - - Text { - anchors.left: aboutIcon.right - anchors.leftMargin: 10 - anchors.top: parent.top - anchors.topMargin: 30 - font.pointSize: 12 - text: "

Mist (0.7.10)


Development

Jeffrey Wilcke
Viktor TrĂ³n
Felix Lange
Taylor Gerring
Daniel Nagy

UX

Alex van de Sande
" - } - } - - Window { - id: txImportDialog - minimumWidth: 270 - maximumWidth: 270 - maximumHeight: 50 - minimumHeight: 50 - TextField { - id: txImportField - width: 170 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 10 - onAccepted: { - } - } - Button { - anchors.left: txImportField.right - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 5 - text: "Import" - onClicked: { - eth.importTx(txImportField.text) - txImportField.visible = false - } - } - Component.onCompleted: { - addrField.focus = true - } - } - - Window { - id: addPeerWin - visible: false - minimumWidth: 400 - maximumWidth: 400 - maximumHeight: 50 - minimumHeight: 50 - title: "Connect to Node" - - TextField { - id: addrField - placeholderText: "enode://::" - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.right: addPeerButton.left - anchors.leftMargin: 10 - anchors.rightMargin: 10 - onAccepted: { - eth.connectToPeer(addrField.text) - addPeerWin.visible = false - } - } - - Button { - id: addPeerButton - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - anchors.rightMargin: 10 - text: "Connect" - onClicked: { - eth.connectToPeer(addrField.text) - addPeerWin.visible = false - } - } - Component.onCompleted: { - addrField.focus = true - } - } - } ->>>>>>> 32a9c0ca809508c1648b8f44f3e09725af7a80d3 + } \ No newline at end of file -- cgit v1.2.3 From 8a0f23915e4feb9aabe21bd075416bc0f32bbc43 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 17:23:09 +0100 Subject: Fixed a few issues in the miner and updated hash rate title * Sometimes old nonces were set by "old" agents * Added the hash rate to the miner --- cmd/mist/assets/qml/main.qml | 4 +++- cmd/mist/assets/qml/views/miner.qml | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index 2b56b7236..dce279518 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -289,6 +289,7 @@ ApplicationWindow { styleColor: "#797979" } + /* Label { //y: 6 objectName: "miningLabel" @@ -307,6 +308,7 @@ ApplicationWindow { anchors.right: peerGroup.left anchors.rightMargin: 5 } + */ ProgressBar { visible: false @@ -1101,4 +1103,4 @@ ApplicationWindow { addrField.focus = true } } - } \ No newline at end of file + } diff --git a/cmd/mist/assets/qml/views/miner.qml b/cmd/mist/assets/qml/views/miner.qml index 193ce37be..0938644b9 100644 --- a/cmd/mist/assets/qml/views/miner.qml +++ b/cmd/mist/assets/qml/views/miner.qml @@ -14,6 +14,30 @@ Rectangle { color: "#00000000" + Label { + visible: false + id: lastBlockLabel + objectName: "lastBlockLabel" + text: "---" + font.pixelSize: 10 + anchors.right: peerGroup.left + anchors.rightMargin: 5 + onTextChanged: { + //menuItem.secondaryTitle = text + } + } + + Label { + objectName: "miningLabel" + visible: false + font.pixelSize: 10 + anchors.right: lastBlockLabel.left + anchors.rightMargin: 5 + onTextChanged: { + menuItem.secondaryTitle = text + } + } + ColumnLayout { spacing: 10 anchors.fill: parent -- cgit v1.2.3 From 218f437b0c2a80aa189e703520b5e1a5b9841b0f Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 17:30:37 +0100 Subject: Updated window --- cmd/mist/assets/qml/main.qml | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index dce279518..1d6b15ac1 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -1054,38 +1054,24 @@ ApplicationWindow { Window { id: addPeerWin visible: false - minimumWidth: 300 - maximumWidth: 300 + minimumWidth: 400 + maximumWidth: 400 maximumHeight: 50 minimumHeight: 50 title: "Connect to peer" - ComboBox { + TextField { id: addrField anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.right: addPeerButton.left anchors.leftMargin: 10 anchors.rightMargin: 10 + placeholderText: "enode://::" onAccepted: { - eth.connectToPeer(addrField.currentText) + eth.connectToPeer(addrField.text) addPeerWin.visible = false } - - editable: true - model: ListModel { id: pastPeers } - - Component.onCompleted: { - pastPeers.insert(0, {text: "poc-8.ethdev.com:30303"}) - /* - var ips = eth.pastPeers() - for(var i = 0; i < ips.length; i++) { - pastPeers.append({text: ips.get(i)}) - } - - pastPeers.insert(0, {text: "poc-7.ethdev.com:30303"}) - */ - } } Button { @@ -1093,7 +1079,7 @@ ApplicationWindow { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter anchors.rightMargin: 10 - text: "Add" + text: "Connect" onClicked: { eth.connectToPeer(addrField.currentText) addPeerWin.visible = false -- cgit v1.2.3 From 790de35e7ff5235c83e081faf00aff35640cdcc6 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 17:57:46 +0100 Subject: Fixed issue in peer window * Fixed issues where new peer window could cause a crash when entering an empty string --- cmd/ethereum/main.go | 2 +- cmd/mist/assets/qml/main.qml | 20 ++++++++++++-------- cmd/mist/main.go | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index d2b3418cd..0dba462be 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -37,7 +37,7 @@ import ( const ( ClientIdentifier = "Ethereum(G)" - Version = "0.8.2" + Version = "0.8.3" ) var clilogger = logger.NewLogger("CLI") diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index 1d6b15ac1..ecc121407 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -61,11 +61,11 @@ ApplicationWindow { function activeView(view, menuItem) { mainSplit.setView(view, menuItem) if (view.hideUrl) { - urlPane.visible = false; - mainView.anchors.top = rootView.top + //urlPane.visible = false; + //mainView.anchors.top = rootView.top } else { - urlPane.visible = true; - mainView.anchors.top = divider.bottom + //urlPane.visible = true; + //mainView.anchors.top = divider.bottom } } @@ -1069,8 +1069,10 @@ ApplicationWindow { anchors.rightMargin: 10 placeholderText: "enode://::" onAccepted: { - eth.connectToPeer(addrField.text) - addPeerWin.visible = false + if(addrField.text.length != 0) { + eth.connectToPeer(addrField.text) + addPeerWin.visible = false + } } } @@ -1081,8 +1083,10 @@ ApplicationWindow { anchors.rightMargin: 10 text: "Connect" onClicked: { - eth.connectToPeer(addrField.currentText) - addPeerWin.visible = false + if(addrField.text.length != 0) { + eth.connectToPeer(addrField.text) + addPeerWin.visible = false + } } } Component.onCompleted: { diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 52b5e4e94..32222fbef 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -36,7 +36,7 @@ import ( const ( ClientIdentifier = "Mist" - Version = "0.8.2" + Version = "0.8.3" ) var ethereum *eth.Ethereum -- cgit v1.2.3 From 0f3c25b26589f5667b618d6a91b73392d02ccd1e Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 18:03:16 +0100 Subject: Propagate blocks --- cmd/mist/gui.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index 6d179eea1..484cda5ff 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -412,9 +412,7 @@ func (gui *Gui) update() { switch ev := ev.(type) { case core.NewBlockEvent: gui.processBlock(ev.Block, false) - if bytes.Compare(ev.Block.Coinbase(), gui.address()) == 0 { - gui.setWalletValue(gui.eth.ChainManager().State().GetBalance(gui.address()), nil) - } + gui.setWalletValue(gui.eth.ChainManager().State().GetBalance(gui.address()), nil) case core.TxPreEvent: tx := ev.Tx -- cgit v1.2.3 From ce239333d529898edd8333637fd75c565e80a9ff Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 18:15:23 +0100 Subject: Update balance label when mining --- cmd/mist/assets/qml/views/wallet.qml | 11 +++++++++++ cmd/mist/gui.go | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/views/wallet.qml b/cmd/mist/assets/qml/views/wallet.qml index 545098284..838fa8749 100644 --- a/cmd/mist/assets/qml/views/wallet.qml +++ b/cmd/mist/assets/qml/views/wallet.qml @@ -15,6 +15,17 @@ Rectangle { objectName: "walletView" anchors.fill: parent + Label { + objectName: "balanceLabel" + visible: false + font.pixelSize: 10 + anchors.right: lastBlockLabel.left + anchors.rightMargin: 5 + onTextChanged: { + menuItem.secondaryTitle = text + } + } + function onReady() { setBalance() } diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index 484cda5ff..c4ce1d463 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -412,7 +412,9 @@ func (gui *Gui) update() { switch ev := ev.(type) { case core.NewBlockEvent: gui.processBlock(ev.Block, false) - gui.setWalletValue(gui.eth.ChainManager().State().GetBalance(gui.address()), nil) + //gui.setWalletValue(gui.eth.ChainManager().State().GetBalance(gui.address()), nil) + balance := ethutil.CurrencyToString(gui.eth.ChainManager().State().GetBalance(gui.address())) + gui.getObjectByName("balanceLabel").Set("text", fmt.Sprintf("%v", balance)) case core.TxPreEvent: tx := ev.Tx -- cgit v1.2.3 From 6a7b0ef904def27c535cba6f85d686bc4dbab281 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 18:17:17 +0100 Subject: Updated coin.js abi --- cmd/mist/assets/examples/coin.js | 113 ++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 56 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/examples/coin.js b/cmd/mist/assets/examples/coin.js index d69af5dcb..77daac846 100644 --- a/cmd/mist/assets/examples/coin.js +++ b/cmd/mist/assets/examples/coin.js @@ -1,64 +1,65 @@ -var contract = web3.eth.contractFromAbi([ +var walletABI = [ { - "constant":false, - "inputs":[ - {"name":"_h","type":"hash256"} - ], - "name":"confirm", - "outputs":[], - "type":"function" + "name":"confirm", + "type":"function", + "constant":false, + "inputs":[ + {"name":"_h","type":"hash256"} + ], + "outputs":[] },{ - "constant":false, - "inputs":[ - {"name":_to,"type":"address"}, - {"name":"_value","type":"uint256"}, - {"name":"_data","type":"bytes"} - ], - "name":"execute", - "outputs":[ - {"name":"_r","type":"hash256"} - ], - "type":"function" + "name":"execute", + "constant":false, + "type":"function", + "inputs":[ + {"name":"_to","type":"address"}, + {"name":"_value","type":"uint256"}, + {"name":"_data","type":"bytes"} + ], + "outputs":[ + {"name":"_r","type":"hash256"} + ] },{ - "constant":false, - "inputs":[ - {"name":"_to","type":"address"} - ],"name":"kill", - "outputs":[], - "type":"function" + "name":"kill", + "type":"function", + "constant":false, + "inputs":[ + {"name":"_to","type":"address"} + ], + "outputs":[] },{ - "constant":false, - "inputs":[ - {"name":"_from","type":"address"}, - {"name":"_to","type":"address"} - ], - "name":"changeOwner", - "outputs":[], - "type":"function" + "name":"changeOwner", + "type":"function", + "constant":false, + "inputs":[ + {"name":"_from","type":"address"}, + {"name":"_to","type":"address"} + ], + "outputs":[] },{ - "inputs":[ - {"indexed":false,"name":"value","type":"uint256"} - ], - "name":"CashIn", - "type":"event" + "name":"CashIn", + "type":"event", + "inputs":[ + {"indexed":false,"name":"value","type":"uint256"} + ] },{ - "inputs":[ - {"indexed":true,"name":"out","type":"string32"}, - {"indexed":false,"name":"owner","type":"address"}, - {"indexed":false,"name":"value","type":"uint256"}, - {"indexed":false,"name":"to","type":"address"} - ], - "name":"SingleTransact", - "type":"event" + "name":"SingleTransact", + "type":"event", + "inputs":[ + {"indexed":true,"name":"out","type":"string32"}, + {"indexed":false,"name":"owner","type":"address"}, + {"indexed":false,"name":"value","type":"uint256"}, + {"indexed":false,"name":"to","type":"address"} + ] },{ - "inputs":[ - {"indexed":true,"name":"out","type":"string32"}, - {"indexed":false,"name":"owner","type":"address"}, - {"indexed":false,"name":"operation","type":"hash256"}, - {"indexed":false,"name":"value","type":"uint256"}, - {"indexed":false,"name":"to","type":"address"} - ], - "name":"MultiTransact", - "type":"event" + "name":"MultiTransact", + "type":"event", + "inputs":[ + {"indexed":true,"name":"out","type":"string32"}, + {"indexed":false,"name":"owner","type":"address"}, + {"indexed":false,"name":"operation","type":"hash256"}, + {"indexed":false,"name":"value","type":"uint256"}, + {"indexed":false,"name":"to","type":"address"} + ] } -]); +]; -- cgit v1.2.3 From 384305f4aa8daef684efc76a374e1d6686c9c83f Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 18:33:08 +0100 Subject: Fixed QML errors --- cmd/mist/assets/qml/views/catalog.qml | 1 - cmd/mist/assets/qml/views/miner.qml | 3 --- cmd/mist/assets/qml/views/wallet.qml | 4 +--- 3 files changed, 1 insertion(+), 7 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/views/catalog.qml b/cmd/mist/assets/qml/views/catalog.qml index a7832e9fa..884493eef 100644 --- a/cmd/mist/assets/qml/views/catalog.qml +++ b/cmd/mist/assets/qml/views/catalog.qml @@ -137,7 +137,6 @@ Rectangle { anchors { left: root.left right: root.right - top: sizeGrip.bottom bottom: root.bottom } diff --git a/cmd/mist/assets/qml/views/miner.qml b/cmd/mist/assets/qml/views/miner.qml index 0938644b9..6a199a925 100644 --- a/cmd/mist/assets/qml/views/miner.qml +++ b/cmd/mist/assets/qml/views/miner.qml @@ -19,9 +19,6 @@ Rectangle { id: lastBlockLabel objectName: "lastBlockLabel" text: "---" - font.pixelSize: 10 - anchors.right: peerGroup.left - anchors.rightMargin: 5 onTextChanged: { //menuItem.secondaryTitle = text } diff --git a/cmd/mist/assets/qml/views/wallet.qml b/cmd/mist/assets/qml/views/wallet.qml index 838fa8749..d1d38bb72 100644 --- a/cmd/mist/assets/qml/views/wallet.qml +++ b/cmd/mist/assets/qml/views/wallet.qml @@ -18,10 +18,8 @@ Rectangle { Label { objectName: "balanceLabel" visible: false - font.pixelSize: 10 - anchors.right: lastBlockLabel.left - anchors.rightMargin: 5 onTextChanged: { + balance.text = text menuItem.secondaryTitle = text } } -- cgit v1.2.3 From 8464e43eaf7d4841f90c8345d6d0afdf3f90ad49 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 13 Feb 2015 23:55:50 +0100 Subject: cmd/mist: fix peer window --- cmd/mist/assets/qml/main.qml | 23 ++++++++--------------- cmd/mist/gui.go | 34 +++++++++++++++++++++++++++++----- cmd/mist/ui_lib.go | 5 ----- 3 files changed, 37 insertions(+), 25 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index ecc121407..fd3e3020a 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -341,7 +341,7 @@ ApplicationWindow { } Label { - id: peerLabel + id: peerCounterLabel font.pixelSize: 10 text: "0 / 0" } @@ -926,7 +926,6 @@ ApplicationWindow { } } - function setWalletValue(value) { walletValueLabel.text = value } @@ -936,17 +935,11 @@ ApplicationWindow { var view = mainView.addPlugin(name) } - function setPeers(text) { - peerLabel.text = text - } - - function addPeer(peer) { - // We could just append the whole peer object but it cries if you try to alter them - peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), latency: peer.latency, version: peer.version, caps: peer.caps}) - } + function clearPeers() { peerModel.clear() } + function addPeer(peer) { peerModel.append(peer) } - function resetPeers(){ - peerModel.clear() + function setPeerCounters(text) { + peerCounterLabel.text = text } function timeAgo(unixTs){ @@ -984,9 +977,9 @@ ApplicationWindow { anchors.fill: parent id: peerTable model: peerModel - TableViewColumn{width: 200; role: "ip" ; title: "IP" } - TableViewColumn{width: 260; role: "version" ; title: "Version" } - TableViewColumn{width: 180; role: "caps" ; title: "Capabilities" } + TableViewColumn{width: 180; role: "addr" ; title: "Remote Address" } + TableViewColumn{width: 280; role: "nodeID" ; title: "Node ID" } + TableViewColumn{width: 180; role: "caps" ; title: "Capabilities" } } } } diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index c4ce1d463..208b553d2 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -31,6 +31,7 @@ import ( "os" "path" "runtime" + "sort" "strconv" "time" @@ -449,6 +450,7 @@ func (gui *Gui) update() { case <-peerUpdateTicker.C: gui.setPeerInfo() + case <-generalUpdateTicker.C: statusText := "#" + gui.eth.ChainManager().CurrentBlock().Number().String() lastBlockLabel.Set("text", statusText) @@ -499,12 +501,34 @@ NumGC: %d )) } +type qmlpeer struct{ Addr, NodeID, Caps string } + +type peersByID []*qmlpeer + +func (s peersByID) Len() int { return len(s) } +func (s peersByID) Less(i, j int) bool { return s[i].NodeID < s[j].NodeID } +func (s peersByID) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + 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) - //} + peers := gui.eth.Peers() + qpeers := make(peersByID, len(peers)) + for i, p := range peers { + qpeers[i] = &qmlpeer{ + NodeID: p.ID().String(), + Addr: p.RemoteAddr().String(), + Caps: fmt.Sprint(p.Caps()), + } + } + // we need to sort the peers because they jump around randomly + // otherwise. order returned by eth.Peers is random because they + // are taken from a map. + sort.Sort(qpeers) + + gui.win.Root().Call("setPeerCounters", fmt.Sprintf("%d / %d", len(peers), gui.eth.MaxPeers())) + gui.win.Root().Call("clearPeers") + for _, p := range qpeers { + gui.win.Root().Call("addPeer", p) + } } func (gui *Gui) privateKey() string { diff --git a/cmd/mist/ui_lib.go b/cmd/mist/ui_lib.go index ab48386f4..368fb002b 100644 --- a/cmd/mist/ui_lib.go +++ b/cmd/mist/ui_lib.go @@ -73,11 +73,6 @@ func (self *UiLib) Notef(args []interface{}) { guilogger.Infoln(args...) } -func (self *UiLib) PastPeers() *ethutil.List { - return ethutil.NewList([]string{}) - //return ethutil.NewList(eth.PastPeers()) -} - func (self *UiLib) ImportTx(rlpTx string) { tx := types.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx)) err := self.eth.TxPool().Add(tx) -- cgit v1.2.3 From 84f7c966f725ef0f5c62b4427857d112c0d1e828 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 14 Feb 2015 00:25:47 +0100 Subject: Moved ECIES to repo & added secondary title for webview * ECIES moved from obscuren to ethereum * Added html META[name=badge] to reflect menuItem.secondaryTitle --- cmd/mist/assets/examples/info.html | 4 ++-- cmd/mist/assets/qml/views/browser.qml | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/examples/info.html b/cmd/mist/assets/examples/info.html index daad8c706..d8816b19f 100644 --- a/cmd/mist/assets/examples/info.html +++ b/cmd/mist/assets/examples/info.html @@ -1,8 +1,8 @@ - + @@ -60,7 +60,7 @@ var web3 = require('web3'); var eth = web3.eth; - web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080')); + web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8545')); document.querySelector("#number").innerHTML = eth.number; document.querySelector("#coinbase").innerHTML = eth.coinbase diff --git a/cmd/mist/assets/qml/views/browser.qml b/cmd/mist/assets/qml/views/browser.qml index 04b2229ec..3cbabf0b6 100644 --- a/cmd/mist/assets/qml/views/browser.qml +++ b/cmd/mist/assets/qml/views/browser.qml @@ -333,6 +333,17 @@ Rectangle { top: navBar.bottom } z: 10 + + Timer { + interval: 500; running: true; repeat: true + onTriggered: { + webview.runJavaScript("document.querySelector('meta[name=badge]').getAttribute('content')", function(badge) { + if (badge) { + menuItem.secondaryTitle = badge; + } + }); + } + } onLoadingChanged: { if (loadRequest.status == WebEngineView.LoadSucceededStatus) { @@ -340,6 +351,7 @@ Rectangle { menuItem.title = pageTitle; }); + //var topBarStyle webView.runJavaScript("document.querySelector(\"meta[name='ethereum-dapp-url-bar-style']\").getAttribute(\"content\")", function(topBarStyle){ if (topBarStyle=="transparent") { -- cgit v1.2.3 From befb4bc1c102a62eaad9b4980e54cd4067078c2a Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 14 Feb 2015 17:13:21 +0100 Subject: Fixed a few errors in the browser special meta tags objects --- cmd/mist/assets/qml/views/browser.qml | 58 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 30 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/views/browser.qml b/cmd/mist/assets/qml/views/browser.qml index 3cbabf0b6..ac160e2b1 100644 --- a/cmd/mist/assets/qml/views/browser.qml +++ b/cmd/mist/assets/qml/views/browser.qml @@ -334,16 +334,16 @@ Rectangle { } z: 10 - Timer { - interval: 500; running: true; repeat: true - onTriggered: { - webview.runJavaScript("document.querySelector('meta[name=badge]').getAttribute('content')", function(badge) { - if (badge) { - menuItem.secondaryTitle = badge; - } - }); - } - } + Timer { + interval: 500; running: true; repeat: true + onTriggered: { + webview.runJavaScript("try{document.querySelector('meta[name=badge]').getAttribute('content')}catch(e){}", function(badge) { + if (badge) { + menuItem.secondaryTitle = badge; + } + }); + } + } onLoadingChanged: { if (loadRequest.status == WebEngineView.LoadSucceededStatus) { @@ -351,31 +351,27 @@ Rectangle { menuItem.title = pageTitle; }); + webView.runJavaScript("try{document.querySelector(\"meta[name='ethereum-dapp-url-bar-style']\").getAttribute(\"content\")}catch(e){}", function(topBarStyle){ + if (!topBarStyle) return; - //var topBarStyle - webView.runJavaScript("document.querySelector(\"meta[name='ethereum-dapp-url-bar-style']\").getAttribute(\"content\")", function(topBarStyle){ if (topBarStyle=="transparent") { - // Adjust for a transparent sidebar Dapp - navBarBackground.visible = false; - back.visible = false; - appInfoPane.anchors.leftMargin = -16; - appInfoPaneShadow.anchors.leftMargin = -16; - webview.anchors.topMargin = -74; + navBarBackground.visible = false; + back.visible = false; + appInfoPane.anchors.leftMargin = -16; + appInfoPaneShadow.anchors.leftMargin = -16; + webview.anchors.topMargin = -74; webview.runJavaScript("document.querySelector('body').classList.add('ethereum-dapp-url-bar-style-transparent')") } else { - navBarBackground.visible = true; - back.visible = true; - appInfoPane.anchors.leftMargin = 0; - appInfoPaneShadow.anchors.leftMargin = 0; - webview.anchors.topMargin = 0; - - }; + navBarBackground.visible = true; + back.visible = true; + appInfoPane.anchors.leftMargin = 0; + appInfoPaneShadow.anchors.leftMargin = 0; + webview.anchors.topMargin = 0; + }; }); - - webview.runJavaScript(eth.readFile("bignumber.min.js")); webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js")); @@ -383,10 +379,12 @@ Rectangle { var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i); var domain = matches && matches[1]; - appDomain.text = domain //webview.url.replace("a", "z") - appTitle.text = webview.title + if (domain) + appDomain.text = domain //webview.url.replace("a", "z") + if (webview.title) + appTitle.text = webview.title - showFullUrlBar(false); + showFullUrlBar(false); } } onJavaScriptConsoleMessage: { -- cgit v1.2.3 From c29b01ce75c1feacf13e57b906ce0613168cd895 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 14 Feb 2015 17:18:28 +0100 Subject: Reset URL bar --- cmd/mist/assets/qml/views/browser.qml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/views/browser.qml b/cmd/mist/assets/qml/views/browser.qml index ac160e2b1..2685f902b 100644 --- a/cmd/mist/assets/qml/views/browser.qml +++ b/cmd/mist/assets/qml/views/browser.qml @@ -352,7 +352,15 @@ Rectangle { }); webView.runJavaScript("try{document.querySelector(\"meta[name='ethereum-dapp-url-bar-style']\").getAttribute(\"content\")}catch(e){}", function(topBarStyle){ - if (!topBarStyle) return; + if (!topBarStyle) { + showFullUrlBar(true); + navBarBackground.visible = true; + back.visible = true; + appInfoPane.anchors.leftMargin = 0; + appInfoPaneShadow.anchors.leftMargin = 0; + webview.anchors.topMargin = 0; + return; + } if (topBarStyle=="transparent") { // Adjust for a transparent sidebar Dapp -- cgit v1.2.3 From 12fc590b34fba3391799fbdfd66ef029f7a551f4 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sun, 15 Feb 2015 01:58:15 +0100 Subject: removed some old menu items --- cmd/mist/assets/qml/main.qml | 29 ----------------------------- cmd/mist/assets/qml/views/browser.qml | 3 --- 2 files changed, 32 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index fd3e3020a..e1e6a028f 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -149,23 +149,6 @@ ApplicationWindow { menuBar: MenuBar { Menu { title: "File" - MenuItem { - text: "Import App" - shortcut: "Ctrl+o" - onTriggered: { - generalFileDialog.show(true, importApp) - } - } - - MenuItem { - text: "Add plugin" - onTriggered: { - generalFileDialog.show(true, function(path) { - addPlugin(path, {close: true, section: "apps"}) - }) - } - } - MenuItem { text: "New tab" shortcut: "Ctrl+t" @@ -262,18 +245,6 @@ ApplicationWindow { } } } - - Menu { - title: "GLOBAL SHORTCUTS" - visible: false - MenuItem { - visible: false - shortcut: "Ctrl+l" - onTriggered: { - url.focus = true - } - } - } } statusBar: StatusBar { diff --git a/cmd/mist/assets/qml/views/browser.qml b/cmd/mist/assets/qml/views/browser.qml index 2685f902b..4d72b9741 100644 --- a/cmd/mist/assets/qml/views/browser.qml +++ b/cmd/mist/assets/qml/views/browser.qml @@ -380,9 +380,6 @@ Rectangle { }; }); - webview.runJavaScript(eth.readFile("bignumber.min.js")); - webview.runJavaScript(eth.readFile("ethereum.js/dist/ethereum.js")); - var cleanTitle = webview.url.toString() var matches = cleanTitle.match(/^[a-z]*\:\/\/([^\/?#]+)(?:[\/?#]|$)/i); var domain = matches && matches[1]; -- cgit v1.2.3 From 2c3a014f03390628d329167109f90a30e3c4e4c3 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sun, 15 Feb 2015 16:16:27 +0100 Subject: Resolved some bugs in the miner * TODO nonce error sometimes persists * Fixed mining on wrong blocks * Fixed state error & receipt fail --- cmd/mist/assets/qml/views/transaction.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/views/transaction.qml b/cmd/mist/assets/qml/views/transaction.qml index 62c762956..6637346b5 100644 --- a/cmd/mist/assets/qml/views/transaction.qml +++ b/cmd/mist/assets/qml/views/transaction.qml @@ -177,7 +177,7 @@ Rectangle { mainContractColumn.state = "ERROR" } else { txResult.text = "Your transaction has been submitted:\n" - txOutput.text = res[0].address + txOutput.text = res.toString() mainContractColumn.state = "DONE" console.log(res) -- cgit v1.2.3 From 164de5e22be39ba2bdc58f84f72572252634e7e1 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 16 Feb 2015 13:20:16 +0100 Subject: Changed default denominators --- cmd/mist/assets/qml/views/browser.qml | 4 +++- cmd/mist/assets/qml/views/transaction.qml | 2 +- cmd/mist/assets/qml/views/wallet.qml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/qml/views/browser.qml b/cmd/mist/assets/qml/views/browser.qml index 4d72b9741..631ef5a16 100644 --- a/cmd/mist/assets/qml/views/browser.qml +++ b/cmd/mist/assets/qml/views/browser.qml @@ -3,7 +3,7 @@ import QtQuick.Controls 1.0; import QtQuick.Controls.Styles 1.0 import QtQuick.Layouts 1.0; import QtWebEngine 1.0 -//import QtWebEngine.experimental 1.0 +import QtWebEngine.experimental 1.0 import QtQuick.Window 2.0; Rectangle { @@ -326,6 +326,8 @@ Rectangle { WebEngineView { objectName: "webView" id: webview + experimental.settings.javascriptCanAccessClipboard: true + experimental.settings.localContentCanAccessRemoteUrls: true anchors { left: parent.left right: parent.right diff --git a/cmd/mist/assets/qml/views/transaction.qml b/cmd/mist/assets/qml/views/transaction.qml index 6637346b5..df798a9c0 100644 --- a/cmd/mist/assets/qml/views/transaction.qml +++ b/cmd/mist/assets/qml/views/transaction.qml @@ -103,7 +103,7 @@ Rectangle { ComboBox { id: valueDenom - currentIndex: 6 + currentIndex: 5 model: denomModel } } diff --git a/cmd/mist/assets/qml/views/wallet.qml b/cmd/mist/assets/qml/views/wallet.qml index d1d38bb72..59dbae848 100644 --- a/cmd/mist/assets/qml/views/wallet.qml +++ b/cmd/mist/assets/qml/views/wallet.qml @@ -104,7 +104,7 @@ Rectangle { ComboBox { id: valueDenom - currentIndex: 6 + currentIndex: 5 model: denomModel } -- cgit v1.2.3