aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-06 02:53:53 +0800
committerobscuren <geffobscura@gmail.com>2015-01-06 02:53:53 +0800
commitc9985bf563888d5f346408d2ff174167e8b65880 (patch)
treef9ef6249248c18ffb9060fc4ccf5ce29ab6f5b65 /xeth
parent22c0c5465a274cad10367aa3f68ca64bf61e90eb (diff)
downloadgo-tangerine-c9985bf563888d5f346408d2ff174167e8b65880.tar
go-tangerine-c9985bf563888d5f346408d2ff174167e8b65880.tar.gz
go-tangerine-c9985bf563888d5f346408d2ff174167e8b65880.tar.bz2
go-tangerine-c9985bf563888d5f346408d2ff174167e8b65880.tar.lz
go-tangerine-c9985bf563888d5f346408d2ff174167e8b65880.tar.xz
go-tangerine-c9985bf563888d5f346408d2ff174167e8b65880.tar.zst
go-tangerine-c9985bf563888d5f346408d2ff174167e8b65880.zip
Fixed peer window. Minor tweaks and fixes
Diffstat (limited to 'xeth')
-rw-r--r--xeth/js_types.go41
1 files changed, 15 insertions, 26 deletions
diff --git a/xeth/js_types.go b/xeth/js_types.go
index 4bb1f4e7d..dbddcb7a3 100644
--- a/xeth/js_types.go
+++ b/xeth/js_types.go
@@ -1,6 +1,7 @@
package xeth
import (
+ "fmt"
"strings"
"github.com/ethereum/go-ethereum/core"
@@ -154,36 +155,24 @@ func NewPReciept(contractCreation bool, creationAddress, hash, address []byte) *
// Peer interface exposed to QML
type JSPeer struct {
- ref *p2p.Peer
- // Inbound bool `json:"isInbound"`
- // LastSend int64 `json:"lastSend"`
- // LastPong int64 `json:"lastPong"`
- // Ip string `json:"ip"`
- // Port int `json:"port"`
- // Version string `json:"version"`
- // LastResponse string `json:"lastResponse"`
- // Latency string `json:"latency"`
- // Caps string `json:"caps"`
+ ref *p2p.Peer
+ Ip string `json:"ip"`
+ Version string `json:"version"`
+ Caps string `json:"caps"`
}
func NewJSPeer(peer *p2p.Peer) *JSPeer {
+ var caps []string
+ for _, cap := range peer.Caps() {
+ caps = append(caps, fmt.Sprintf("%s/%d", cap.Name, cap.Version))
+ }
- // var ip []string
- // for _, i := range peer.Host() {
- // ip = append(ip, strconv.Itoa(int(i)))
- // }
- // ipAddress := strings.Join(ip, ".")
-
- // var caps []string
- // capsIt := peer.Caps().NewIterator()
- // for capsIt.Next() {
- // cap := capsIt.Value().Get(0).Str()
- // ver := capsIt.Value().Get(1).Uint()
- // caps = append(caps, fmt.Sprintf("%s/%d", cap, ver))
- // }
-
- return &JSPeer{ref: peer}
- // return &JSPeer{ref: &peer, Inbound: peer.Inbound(), LastSend: peer.LastSend().Unix(), LastPong: peer.LastPong(), Version: peer.Version(), Ip: ipAddress, Port: int(peer.Port()), Latency: peer.PingTime(), Caps: "[" + strings.Join(caps, ", ") + "]"}
+ return &JSPeer{
+ ref: peer,
+ Ip: peer.RemoteAddr().String(),
+ Version: peer.Identity().String(),
+ Caps: fmt.Sprintf("%v", caps),
+ }
}
type JSReceipt struct {