aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/mist/assets/qml/main.qml44
-rw-r--r--cmd/mist/ui_lib.go12
-rw-r--r--eth/backend.go10
-rw-r--r--javascript/javascript_runtime.go11
-rw-r--r--p2p/server.go4
-rw-r--r--p2p/server_test.go2
6 files changed, 21 insertions, 62 deletions
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://<hex node id>:<IP address>:<port>"
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())
}
}
diff --git a/eth/backend.go b/eth/backend.go
index 08052c15d..6cf2069d7 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -2,7 +2,6 @@ package eth
import (
"fmt"
- "net"
"sync"
"github.com/ethereum/go-ethereum/core"
@@ -241,13 +240,12 @@ func (s *Ethereum) Start(seedNode string) error {
return nil
}
-func (self *Ethereum) SuggestPeer(addr string, id discover.NodeID) error {
- netaddr, err := net.ResolveTCPAddr("tcp", addr)
+func (self *Ethereum) SuggestPeer(nodeURL string) error {
+ n, err := discover.ParseNode(nodeURL)
if err != nil {
- logger.Errorf("couldn't resolve %s:", addr, err)
- return err
+ return fmt.Errorf("invalid node URL: %v", err)
}
- self.net.SuggestPeer(netaddr.IP, netaddr.Port, id)
+ self.net.SuggestPeer(n)
return nil
}
diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go
index a09aff027..0aa0f73e2 100644
--- a/javascript/javascript_runtime.go
+++ b/javascript/javascript_runtime.go
@@ -14,7 +14,6 @@ import (
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/xeth"
"github.com/obscuren/otto"
@@ -198,19 +197,13 @@ func (self *JSRE) watch(call otto.FunctionCall) otto.Value {
}
func (self *JSRE) addPeer(call otto.FunctionCall) otto.Value {
- host, err := call.Argument(0).ToString()
+ nodeURL, err := call.Argument(0).ToString()
if err != nil {
return otto.FalseValue()
}
- idstr, err := call.Argument(0).ToString()
- if err != nil {
- return otto.FalseValue()
- }
- id, err := discover.HexID(idstr)
- if err != nil {
+ if err := self.ethereum.SuggestPeer(nodeURL); err != nil {
return otto.FalseValue()
}
- self.ethereum.SuggestPeer(host, id)
return otto.TrueValue()
}
diff --git a/p2p/server.go b/p2p/server.go
index c6d7fc2e8..bb3101485 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -135,8 +135,8 @@ func (srv *Server) PeerCount() int {
// SuggestPeer creates a connection to the given Node if it
// is not already connected.
-func (srv *Server) SuggestPeer(ip net.IP, port int, id discover.NodeID) {
- srv.peerConnect <- &discover.Node{ID: id, IP: ip, TCPPort: port}
+func (srv *Server) SuggestPeer(n *discover.Node) {
+ srv.peerConnect <- n
}
// Broadcast sends an RLP-encoded message to all connected peers.
diff --git a/p2p/server_test.go b/p2p/server_test.go
index d1e1640fb..aa2b3d243 100644
--- a/p2p/server_test.go
+++ b/p2p/server_test.go
@@ -91,7 +91,7 @@ func TestServerDial(t *testing.T) {
// tell the server to connect
tcpAddr := listener.Addr().(*net.TCPAddr)
- srv.peerConnect <- &discover.Node{IP: tcpAddr.IP, TCPPort: tcpAddr.Port}
+ srv.SuggestPeer(&discover.Node{IP: tcpAddr.IP, TCPPort: tcpAddr.Port})
select {
case conn := <-accepted: